|
|
|
@ -185,6 +185,12 @@ namespace Avalonia.Data |
|
|
|
return new BindingValue<T>(type | BindingValueType.HasValue, value, Error); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the value of the binding value if present, otherwise the default value.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
public T GetValueOrDefault() => HasValue ? _value : default; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the value of the binding value if present, otherwise a default value.
|
|
|
|
/// </summary>
|
|
|
|
@ -192,6 +198,20 @@ namespace Avalonia.Data |
|
|
|
/// <returns>The value.</returns>
|
|
|
|
public T GetValueOrDefault(T defaultValue = default) => HasValue ? _value : defaultValue; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the value if present, otherwise the default value.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>
|
|
|
|
/// The value if present and of the correct type, `default(TResult)` if the value is
|
|
|
|
/// not present or of an incorrect type.
|
|
|
|
/// </returns>
|
|
|
|
public TResult GetValueOrDefault<TResult>() |
|
|
|
{ |
|
|
|
return HasValue ? |
|
|
|
_value is TResult result ? result : default |
|
|
|
: default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the value of the binding value if present, otherwise a default value.
|
|
|
|
/// </summary>
|
|
|
|
|