Class OptionCollection
- Namespace
- ArcanaDevelopment.adTempus.Client.Collections
- Assembly
- ArcanaDevelopment.adTempus.Client.dll
A collection of Option objects
public sealed class OptionCollection : ObjectBaseCollectionT<Option>
- Inheritance
-
objectOptionCollection
Methods
Add(Option)
Adds a new option
public override void Add(Option newOption)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
createIfNonExistentif false; otherwise the method creates a new option with nameoptionName, 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
defaultValueif 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
| Name | Type | Description |
|---|---|---|
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
defaultValueif 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
| Name | Type | Description |
|---|---|---|
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
defaultValueif 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
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
defaultValueif the collection does not contain an option with that name or the value cannot be converted to the required type.
Type Parameters
| Name | Description |
|---|---|
T |
GetOptionValueAsInt(string)
Gets the value of the option with the specified name
public int? GetOptionValueAsInt(string optionName)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
index |
int | The zero-based index of the element to remove. |
Exceptions
- ArgumentOutOfRangeException
indexis less than 0.
-or-
indexis 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Description |
|---|---|
T |
Remarks
This method looks for an existing option with the specified optionName. If none exists, it is created.
Inherited Members
- ObjectCollectionT<Option>.IsReadOnly
- ObjectCollectionT<Option>.Contains(Option)
- ObjectCollectionT<Option>.CopyTo(Option[], int)
- ObjectCollectionT<Option>.Count
- ObjectCollectionT<Option>.Clear()
- ObjectCollectionT<Option>.Remove(Option)
- ObjectCollectionT<Option>.MoveUp(Option)
- ObjectCollectionT<Option>.MoveDown(Option)
- ObjectCollectionT<Option>.MoveItem(Option, int)
- ObjectCollectionT<Option>.MoveItem(int, int)
- ObjectCollectionT<Option>.this[int]
- ObjectCollectionT<Option>.IndexOf(Option)
- ObjectCollectionT<Option>.Insert(int, Option)