Class NameValueCollectionExtensions
Useful extension methods for NameValueCollection.
Inherited Members
Namespace: Libplanet.Common
Assembly: Libplanet.Common.dll
Syntax
public static class NameValueCollectionExtensions
Methods
| Improve this Doc View SourceGetBoolean(NameValueCollection, String, Boolean)
Tries to get the boolean text associated with the specified name as
a Boolean value from the specified name-value collection.
Supported keywords are: true, false,
yes, no, on, off, t, f, y, n,
1, 0 (all case-insensitive).
Declaration
public static bool GetBoolean(this NameValueCollection collection, string name, bool defaultValue = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NameValueCollection | collection | The NameValueCollection that contains the entry to find. |
| String | name | The String key of the entry that contains the value to find. |
| Boolean | defaultValue | Returns this value if the specified key
|
Returns
| Type | Description |
|---|---|
| Boolean | A Boolean value converted from the text value associated with
the specified key |
GetInt32(NameValueCollection, String, Int32)
Tries to get the numeric text associated with the specified name as
an Int32 value from the specified name-value collection.
Declaration
public static int GetInt32(this NameValueCollection collection, string name, int defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| NameValueCollection | collection | The NameValueCollection that contains the entry to find. |
| String | name | The String key of the entry that contains the value to find. |
| Int32 | defaultValue | Returns this value if the specified key
|
Returns
| Type | Description |
|---|---|
| Int32 | An Int32 value converted from the text value associated with
the specified key |
GetInt32(NameValueCollection, String)
Tries to get the numeric text associated with the specified name as
an Int32 value from the specified name-value collection.
Declaration
public static int? GetInt32(this NameValueCollection collection, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| NameValueCollection | collection | The NameValueCollection that contains the entry to find. |
| String | name | The String key of the entry that contains the value to find. |
Returns
| Type | Description |
|---|---|
| Nullable<Int32> | An Int32 value converted from the text value associated with
the specified key |
Remarks
This method assumes the collection contains zero or
one entry for the specified name.
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown when the value is not a numeric text. |
| OverflowException | Thrown when the value is outside the range of the Int32 type. |
GetUInt64(NameValueCollection, String, UInt64)
Tries to get the numeric text associated with the specified name as
a UInt64 value from the specified name-value collection.
Declaration
public static ulong GetUInt64(this NameValueCollection collection, string name, ulong defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| NameValueCollection | collection | The NameValueCollection that contains the entry to find. |
| String | name | The String key of the entry that contains the value to find. |
| UInt64 | defaultValue | Returns this value if the specified key
|
Returns
| Type | Description |
|---|---|
| UInt64 | An Int32 value converted from the text value associated with
the specified key |
GetUInt64(NameValueCollection, String)
Tries to get the numeric text associated with the specified name as
a UInt64 value from the specified name-value collection.
Declaration
public static ulong? GetUInt64(this NameValueCollection collection, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| NameValueCollection | collection | The NameValueCollection that contains the entry to find. |
| String | name | The String key of the entry that contains the value to find. |
Returns
| Type | Description |
|---|---|
| Nullable<UInt64> | A UInt64 value converted from the text value associated with
the specified key |
Remarks
This method assumes the collection contains zero or
one entry for the specified name.
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown when the value is not a numeric text. |
| OverflowException | Thrown when the value is outside the range of the UInt64 type. |