Class NameVauleCollectionExtensions
Summary description for NameVauleCollectionExtensions.
Inheritance
System.Object
NameVauleCollectionExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: ImageVault.Common.Lib.Collections.Specialized
Assembly: ImageVault.Common.dll
Syntax
public static class NameVauleCollectionExtensions
Methods
GetAsBool(NameValueCollection, String, Boolean)
Gets an appsettings as a boolean value
Declaration
public static bool GetAsBool(this NameValueCollection appSettings, string key, bool defaultValue = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | appSettings | The System.Collections.Specialized.NameValueCollection to use |
System.String | key | The key of the appsettings value to get |
System.Boolean | defaultValue | If no value is defined, the default value will be returned |
Returns
Type | Description |
---|---|
System.Boolean | The value as a booelan. False is anything that isn't true. True is (true, yes, on, 1 (ignoring case)). |
GetAsInt(NameValueCollection, String, Int32)
Declaration
public static int GetAsInt(this NameValueCollection appSettings, string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | appSettings | |
System.String | key | |
System.Int32 | defaultValue |
Returns
Type | Description |
---|---|
System.Int32 |
GetAsTimeSpan(NameValueCollection, String, Nullable<TimeSpan>)
Gets an appsettings value as a TimeSpan
Declaration
public static TimeSpan GetAsTimeSpan(this NameValueCollection appSettings, string key, TimeSpan? defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | appSettings | The System.Collections.Specialized.NameValueCollection to use |
System.String | key | The key of the appsettings value to get |
System.Nullable<System.TimeSpan> | defaultValue | The default value to return if the value is unparseable or missing. If no default value, System.TimeSpan.Zero will be used |
Returns
Type | Description |
---|---|
System.TimeSpan | The parsed value |
Remarks
If an integer is found, this is interpreted as the number of minutes.