SettingValues.ValueOrDefault Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| ValueOrDefault<T>(SettingIdentifier<T>, T) |
Gets the value converted to the type |
| ValueOrDefault<T>(Setting+ObjectArray, T[]) |
Gets the value converted to the type |
| ValueOrDefault<T>(Setting<T>, T) |
Gets the value converted to the type |
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
The value converted to the type T.
Exceptions
If T is not a supported type of Setting<T>.
Applies to
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
The value converted to the type T.
Exceptions
If T is not a supported type of Setting<T>.
Applies to
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
The value converted to the type T.
Exceptions
If T is not a supported type of Setting<T>.