Table of Contents

Class OptionCollection

Namespace
ArcanaDevelopment.adTempus.Client.Collections
Assembly
ArcanaDevelopment.adTempus.Client.dll

A collection of Option objects

public sealed class OptionCollection : ObjectBaseCollectionT<Option>
Inheritance
object
OptionCollection

Methods

Add(Option)

Adds a new option

public override void Add(Option newOption)

Parameters

NameTypeDescription
newOption Option

The option to add

Remarks

The new option must have a unique OptionName

Exceptions

DuplicateItemException

Thrown if the collection already contains an option with the same OptionName

ContainsKey(string)

Determines whether the collection contains an option with the specified name

public bool ContainsKey(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

bool

Get(string, bool)

Gets the option with the specified name, optionally creating the option if it does not exist

public Option Get(string optionName, bool createIfNonExistent = true)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

createIfNonExistent bool

If true, the option is created if it does not exist.

Returns

Option

The option with the specified name. If the collection does not contain an option with that name, returns null if createIfNonExistent if false; otherwise the method creates a new option with name optionName, adds it to the collection, and returns it.

GetOptionValue(string)

Gets the value of the option with the specified name

public string GetOptionValue(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

string

The OptionValue of the option with the specified name, or null if the collection does not contain an option with that name.

GetOptionValue(string, bool)

Gets the value of the option with the specified name

public bool GetOptionValue(string optionName, bool defaultValue)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

defaultValue bool

The default value to return if the option does not exist

Returns

bool

The OptionValue of the option with the specified name, or defaultValue if the collection does not contain an option with that name or the value cannot be converted to the required type.

GetOptionValue(string, int)

Gets the value of the option with the specified name

public int GetOptionValue(string optionName, int defaultValue)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

defaultValue int

The default value to return if the option does not exist

Returns

int

The OptionValue of the option with the specified name, or defaultValue if the collection does not contain an option with that name or the value cannot be converted to the required type.

GetOptionValue(string, string)

Gets the value of the option with the specified name

public string GetOptionValue(string optionName, string defaultValue)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

defaultValue string

The default value to return if the option does not exist

Returns

string

The OptionValue of the option with the specified name, or defaultValue if the collection does not contain an option with that name.

GetOptionValueAsBool(string)

Gets the value of the option with the specified name

public bool? GetOptionValueAsBool(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

bool?

The OptionValue of the option with the specified name, or null if the collection does not contain an option with that name or the value cannot be converted to the required type.

GetOptionValueAsDateTime(string)

Gets the value of the option with the specified name

public DateTime? GetOptionValueAsDateTime(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

DateTime?

The OptionValue of the option with the specified name, or null if the collection does not contain an option with that name or the value cannot be converted to the required type.

GetOptionValueAsEnum<T>(string)

Gets the value of the option with the specified name

public T? GetOptionValueAsEnum<T>(string optionName) where T : struct, Enum

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

T?

The OptionValue of the option with the specified name, or null if the collection does not contain an option with that name or the value cannot be converted to the required type.

Type Parameters

NameDescription
T

GetOptionValueAsEnum<T>(string, T)

Gets the value of the option with the specified name

public T GetOptionValueAsEnum<T>(string optionName, T defaultValue) where T : struct, Enum

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

defaultValue T

Returns

T

The OptionValue of the option with the specified name, or defaultValue if the collection does not contain an option with that name or the value cannot be converted to the required type.

Type Parameters

NameDescription
T

GetOptionValueAsInt(string)

Gets the value of the option with the specified name

public int? GetOptionValueAsInt(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to get (case-insensitive)

Returns

int?

The OptionValue of the option with the specified name, or null if the collection does not contain an option with that name or the value cannot be converted to the required type.

Remove(string)

Removes the option with the specified OptionName

public bool Remove(string optionName)

Parameters

NameTypeDescription
optionName string

The name of the option to remove (case-insensitive)

Returns

bool

true if the option was removed, or false if the collection does not contain an option with that name

RemoveAt(int)

Removes the element at the specified index of the System.Collections.Generic.List<T>.

public override void RemoveAt(int index)

Parameters

NameTypeDescription
index int

The zero-based index of the element to remove.

Exceptions

ArgumentOutOfRangeException

index is less than 0.
-or-
index is equal to or greater than System.Collections.Generic.List<T>.Count.

SetOptionValue(string, bool?)

Sets the value of the option with the specified name, creating the option if necessary

public Option SetOptionValue(string optionName, bool? value)

Parameters

NameTypeDescription
optionName string

The name of the option to set (case-insensitive)

value bool?

The new value for the option

Returns

Option

The new or existing Option

Remarks

This method looks for an existing option with the specified optionName. If none exists, it is created.

SetOptionValue(string, DateTime?)

Sets the value of the option with the specified name, creating the option if necessary

public Option SetOptionValue(string optionName, DateTime? value)

Parameters

NameTypeDescription
optionName string

The name of the option to set (case-insensitive)

value DateTime?

The new value for the option

Returns

Option

The new or existing Option

Remarks

This method looks for an existing option with the specified optionName. If none exists, it is created.

SetOptionValue(string, int?)

Sets the value of the option with the specified name, creating the option if necessary

public Option SetOptionValue(string optionName, int? value)

Parameters

NameTypeDescription
optionName string

The name of the option to set (case-insensitive)

value int?

The new value for the option

Returns

Option

The new or existing Option

Remarks

This method looks for an existing option with the specified optionName. If none exists, it is created.

SetOptionValue(string, string)

Sets the value of the option with the specified name, creating the option if necessary

public Option SetOptionValue(string optionName, string value)

Parameters

NameTypeDescription
optionName string

The name of the option to set (case-insensitive)

value string

The new value for the option

Returns

Option

The new or existing Option

Remarks

This method looks for an existing option with the specified optionName. If none exists, it is created.

SetOptionValue<T>(string, T?)

Sets the value of the option with the specified name, creating the option if necessary

public Option SetOptionValue<T>(string optionName, T? value) where T : struct, Enum

Parameters

NameTypeDescription
optionName string

The name of the option to set (case-insensitive)

value T?

The new value for the option

Returns

Option

The new or existing Option

Type Parameters

NameDescription
T

Remarks

This method looks for an existing option with the specified optionName. If none exists, it is created.

Inherited Members

Extension Methods