Class BindingNotification
Represents a binding notification that can be a valid binding value, or a binding or data validation error.
public class BindingNotification
- Inheritance
-
BindingNotification
- Inherited Members
Remarks
This class is very similar to BindingValue<T>, but where BindingValue<T> is used by typed bindings, this class is used to hold binding and data validation errors in untyped bindings. As Avalonia moves towards using typed bindings by default we may want to remove this class.
Constructors
BindingNotification(Exception, BindingErrorType)
Initializes a new instance of the BindingNotification class.
public BindingNotification(Exception error, BindingErrorType errorType)
Parameters
error
ExceptionThe binding error.
errorType
BindingErrorTypeThe type of the binding error.
BindingNotification(Exception, BindingErrorType, object?)
Initializes a new instance of the BindingNotification class.
public BindingNotification(Exception error, BindingErrorType errorType, object? fallbackValue)
Parameters
error
ExceptionThe binding error.
errorType
BindingErrorTypeThe type of the binding error.
fallbackValue
objectThe fallback value.
BindingNotification(object?)
Initializes a new instance of the BindingNotification class.
public BindingNotification(object? value)
Parameters
value
objectThe binding value.
Fields
Null
A binding notification representing the null value.
public static readonly BindingNotification Null
Field Value
UnsetValue
A binding notification representing UnsetValue.
public static readonly BindingNotification UnsetValue
Field Value
Properties
Error
Gets the error that occurred on the source, if any.
public Exception? Error { get; set; }
Property Value
ErrorType
Gets the type of error that Error represents, if any.
public BindingErrorType ErrorType { get; set; }
Property Value
HasValue
Gets a value indicating whether Value should be pushed to the target.
public bool HasValue { get; }
Property Value
Value
Gets the value that should be passed to the target when HasValue is true.
public object? Value { get; }
Property Value
Remarks
If this property is read when HasValue is false then it will return UnsetValue.
Methods
AddError(Exception, BindingErrorType)
Adds an error to the BindingNotification.
public void AddError(Exception e, BindingErrorType type)
Parameters
e
ExceptionThe error to add.
type
BindingErrorTypeThe error type.
ClearValue()
public void ClearValue()
Equals(BindingNotification?)
Compares a value to an instance of BindingNotification for equality.
public bool Equals(BindingNotification? other)
Parameters
other
BindingNotificationThe value to compare.
Returns
- bool
true if the two instances are equal; otherwise false.
Equals(object?)
Compares an object to an instance of BindingNotification for equality.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare.
Returns
- bool
true if the two instances are equal; otherwise false.
ExtractError(object?)
Gets an exception from an object that may be a BindingNotification.
public static object? ExtractError(object? o)
Parameters
o
objectThe object.
Returns
- object
The value.
Remarks
If o
is a BindingNotification then returns the binding
notification's Error. If not, returns the object unchanged.
ExtractValue(object?)
Gets a value from an object that may be a BindingNotification.
public static object? ExtractValue(object? o)
Parameters
o
objectThe object.
Returns
- object
The value.
Remarks
If o
is a BindingNotification then returns the binding
notification's Value. If not, returns the object unchanged.
GetHashCode()
Gets the hash code for this instance of BindingNotification.
public override int GetHashCode()
Returns
- int
A hash code.
SetValue(object?)
Sets the Value.
public void SetValue(object? value)
Parameters
value
object
ToString()
public override string ToString()
Returns
UpdateValue(object?, object)
Updates the value of an object that may be a BindingNotification.
public static object? UpdateValue(object? o, object value)
Parameters
Returns
- object
The updated binding notification if
o
is a binding notification; otherwisevalue
.
Remarks
If o
is a BindingNotification then sets its value
to value
. If value
is a
BindingNotification then the value will first be extracted.
Operators
operator ==(BindingNotification?, BindingNotification?)
Compares two instances of BindingNotification for equality.
public static bool operator ==(BindingNotification? a, BindingNotification? b)
Parameters
a
BindingNotificationThe first instance.
b
BindingNotificationThe second instance.
Returns
- bool
true if the two instances are equal; otherwise false.
operator !=(BindingNotification?, BindingNotification?)
Compares two instances of BindingNotification for inequality.
public static bool operator !=(BindingNotification? a, BindingNotification? b)
Parameters
a
BindingNotificationThe first instance.
b
BindingNotificationThe second instance.
Returns
- bool
true if the two instances are unequal; otherwise false.