Click or drag to resize

AzureTableSettingsGetSettingT(Object, Object, T) Method

Gets a generic type of value of a setting, or a default fallback value if the setting is not found.

This method can be used to get custom Types from a setting's value. An attempt is made to deserialize the setting's raw string value into the requested return Type. If deserialization fails, then processing continues as if the setting was not found, which returns the Type's default value or the fallback parameter value if it's available.

This method is suitable for enum Types.


Namespace: Orthogonal.NSettings.AzureTable
Assembly: Orthogonal.NSettings.AzureTable (in Orthogonal.NSettings.AzureTable.dll) Version: 3.0.5
Syntax
C#
public Task<T> GetSetting<T>(
	Object? appKey,
	Object itemKey,
	T fallback
)

Parameters

appKey  Object
  • An object that optionally provides the application primary key part of the two-part key for a setting. The object value is internally converted to a key string by calling its ToString method. A null value is allowed which is suitable for settings which are not associated with any specific application or perhaps shared between applications.
  • An application primary key can be used to partition settings into groups so they can be more easily managed, such as listing or deleting them all at the application key level.
  • The application key is case sensitive.
  • Hint: It is good coding practise to specify the application key as an enumerated value or a global string constant.
itemKey  Object
  • An object that provides the item secondary key part of the two-part key for a setting. The object value is internally converted to a key string by calling its ToString method.
  • The item key is case sensitive.
  • Hint: It is good coding practise to specify the item key using the C# or Visual Basic nameof operator.
fallback  T
A default value (aka fallback value) to return if no setting is found with the specified appKey and itemKey.

Type Parameters

T
The type of the value to return from the setting.

Return Value

TaskT
A Task representing the asynchronous operation. The completed Task's Result property contains the setting's value if it exists. If the setting is not found then the fallback value is returned.
Remarks

When a setting is not found, the return value for an enum Type depends on which Type is requested and the definition of the enum values.

Calling GetSetting<SomeEnum>(...) with a non-nullable Type will return zero if the setting doesn't exist. If one of the enum values is defined as zero then that enum value is returned, otherwise an undefined enum value is returned.

Calling GetSetting<SomeEnum?>(...) with a nullable Type will return null if the setting doesn't exist.

See Also