Class NameValueCollectionExtensions
Useful extension methods for
Inheritance
Namespace: Libplanet.Common
Assembly: Libplanet.Common.dll
Syntax
public static class NameValueCollectionExtensions : object
Methods
| Improve this Doc View SourceGetBoolean(NameValueCollection, String, Boolean)
Tries to get the boolean text associated with the specified name
as
a 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 |
System.String | name | The |
System.Boolean | defaultValue | Returns this value if the specified key
|
Returns
Type | Description |
---|---|
System.Boolean | A |
GetEnum<T>(NameValueCollection, String, T)
Tries to get the text associated with the specified name
as
given T
value from the specified
name-value collection
.
Declaration
public static T GetEnum<T>(this NameValueCollection collection, string name, T defaultValue)
where T : struct, Enum
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
T | defaultValue | Returns this value if the specified key
|
Returns
Type | Description |
---|---|
T | A |
Type Parameters
Name | Description |
---|---|
T | The |
GetEnum<T>(NameValueCollection, String)
Tries to get the text associated with the specified name
as
given T
value from the specified
name-value collection
.
Declaration
public static T? GetEnum<T>(this NameValueCollection collection, string name)
where T : struct, Enum
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
Returns
Type | Description |
---|---|
System.Nullable<T> | A |
Type Parameters
Name | Description |
---|---|
T | The |
Remarks
This method assumes the collection
contains zero or
one entry for the specified name
.
GetInt32(NameValueCollection, String, Int32)
Tries to get the numeric text associated with the specified name
as
an collection
.
Declaration
public static int GetInt32(this NameValueCollection collection, string name, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
System.Int32 | defaultValue | Returns this value if the specified key
|
Returns
Type | Description |
---|---|
System.Int32 | An |
GetInt32(NameValueCollection, String)
Tries to get the numeric text associated with the specified name
as
an collection
.
Declaration
public static int? GetInt32(this NameValueCollection collection, string name)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | An |
Remarks
This method assumes the collection
contains zero or
one entry for the specified name
.
GetUInt64(NameValueCollection, String, UInt64)
Tries to get the numeric text associated with the specified name
as
a collection
.
Declaration
public static ulong GetUInt64(this NameValueCollection collection, string name, ulong defaultValue)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
System.UInt64 | defaultValue | Returns this value if the specified key
|
Returns
Type | Description |
---|---|
System.UInt64 | An |
GetUInt64(NameValueCollection, String)
Tries to get the numeric text associated with the specified name
as
a collection
.
Declaration
public static ulong? GetUInt64(this NameValueCollection collection, string name)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | collection | The |
System.String | name | The |
Returns
Type | Description |
---|---|
System.Nullable<System.UInt64> | A |
Remarks
This method assumes the collection
contains zero or
one entry for the specified name
.