Share via


SettingValues.ValueOrDefault Method

Definition

Overloads

ValueOrDefault<T>(SettingIdentifier<T>, T)

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

ValueOrDefault<T>(Setting+ObjectArray, T[])

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

ValueOrDefault<T>(Setting<T>, T)

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

ValueOrDefault<T>(SettingIdentifier<T>, T)

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

public T ValueOrDefault<T> (Microsoft.VisualStudio.Extensibility.Settings.SettingIdentifier<T> settingId, T defaultValue);
member this.ValueOrDefault : Microsoft.VisualStudio.Extensibility.Settings.SettingIdentifier<'T> * 'T -> 'T
Public Function ValueOrDefault(Of T) (settingId As SettingIdentifier(Of T), defaultValue As T) As T

Type Parameters

T

The expected type of the setting, only valid types for Setting<T> are supported.

Parameters

settingId
SettingIdentifier<T>

The full identifier of the setting, including the categories it is nested under.

defaultValue
T

The value to return in case of error reading the setting's value.

Returns

T

The value converted to the type T.

Exceptions

If T is not a supported type of Setting<T>.

Applies to

ValueOrDefault<T>(Setting+ObjectArray, T[])

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

public T[] ValueOrDefault<T> (Microsoft.VisualStudio.Extensibility.Settings.Setting.ObjectArray setting, T[] defaultValue) where T : Microsoft.VisualStudio.Extensibility.Settings.IArraySettingItemConvertible, new();
member this.ValueOrDefault : Microsoft.VisualStudio.Extensibility.Settings.Setting.ObjectArray * 'T[] -> 'T[] (requires 'T :> Microsoft.VisualStudio.Extensibility.Settings.IArraySettingItemConvertible and 'T : (new : unit -> 'T))
Public Function ValueOrDefault(Of T As {IArraySettingItemConvertibleNew}) (setting As Setting.ObjectArray, defaultValue As T()) As T()

Type Parameters

T

The expected type of the setting, only valid types for Setting<T> are supported.

Parameters

setting
Setting.ObjectArray

The setting for which the value is to be retrieved.

defaultValue
T[]

The value to return in case of error reading the setting's value.

Returns

T[]

The value converted to the type T.

Exceptions

If T is not a supported type of Setting<T>.

Applies to

ValueOrDefault<T>(Setting<T>, T)

Gets the value converted to the type T, if the retrieval and the conversion to T are successful. Returns defaultValue otherwise.

public T ValueOrDefault<T> (Microsoft.VisualStudio.Extensibility.Settings.Setting<T> setting, T defaultValue);
member this.ValueOrDefault : Microsoft.VisualStudio.Extensibility.Settings.Setting<'T> * 'T -> 'T
Public Function ValueOrDefault(Of T) (setting As Setting(Of T), defaultValue As T) As T

Type Parameters

T

The expected type of the setting, only valid types for Setting<T> are supported.

Parameters

setting
Setting<T>

The setting for which the value is to be retrieved.

defaultValue
T

The value to return in case of error reading the setting's value.

Returns

T

The value converted to the type T.

Exceptions

If T is not a supported type of Setting<T>.

Applies to