/// <summary> /// Initializes a new instance of the <see cref="BindingNotification"/> class. /// </summary> /// <param name="error">The binding error.</param> /// <param name="errorType">The type of the binding error.</param> public BindingNotification(Exception error, BindingErrorType errorType) { if (errorType == BindingErrorType.None) { throw new ArgumentException($"'errorType' may not be None"); } Error = error; ErrorType = errorType; }
/// <summary> /// Initializes a new instance of the <see cref="BindingNotification"/> class. /// </summary> /// <param name="error">The binding error.</param> /// <param name="errorType">The type of the binding error.</param> public BindingNotification(Exception error, BindingErrorType errorType) { if (errorType == BindingErrorType.None) { throw new ArgumentException($"'errorType' may not be None"); } Error = error; ErrorType = errorType; _value = AvaloniaProperty.UnsetValue; }
/// <summary> /// Adds an error to the <see cref="BindingNotification"/>. /// </summary> /// <param name="e">The error to add.</param> /// <param name="type">The error type.</param> public void AddError(Exception e, BindingErrorType type) { Contract.Requires <ArgumentNullException>(e != null); Contract.Requires <ArgumentException>(type != BindingErrorType.None); Error = Error != null ? new AggregateException(Error, e) : e; if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error) { ErrorType = BindingErrorType.Error; } }
/// <summary> /// Adds an error to the <see cref="BindingNotification"/>. /// </summary> /// <param name="e">The error to add.</param> /// <param name="type">The error type.</param> public void AddError(Exception e, BindingErrorType type) { _ = e ?? throw new ArgumentNullException(nameof(e)); if (type == BindingErrorType.None) { throw new ArgumentException("BindingErrorType may not be None", nameof(type)); } Error = Error != null ? new AggregateException(Error, e) : e; if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error) { ErrorType = BindingErrorType.Error; } }
/// <summary> /// Initializes a new instance of the <see cref="BindingNotification"/> class. /// </summary> /// <param name="error">The binding error.</param> /// <param name="errorType">The type of the binding error.</param> /// <param name="fallbackValue">The fallback value.</param> public BindingNotification(Exception error, BindingErrorType errorType, object?fallbackValue) : this(error, errorType) { _value = fallbackValue; }
/// <summary> /// Initializes a new instance of the <see cref="BindingNotification"/> class. /// </summary> /// <param name="error">The binding error.</param> /// <param name="errorType">The type of the binding error.</param> /// <param name="fallbackValue">The fallback value.</param> public BindingNotification(Exception error, BindingErrorType errorType, object fallbackValue) : this(error, errorType) { _value = new WeakReference <object>(fallbackValue ?? NullValue); }
/// <summary> /// Initializes a new instance of the <see cref="BindingNotification"/> class. /// </summary> /// <param name="error">The binding error.</param> /// <param name="errorType">The type of the binding error.</param> /// <param name="fallbackValue">The fallback value.</param> public BindingNotification(Exception error, BindingErrorType errorType, object fallbackValue) : this(error, errorType) { _value = new WeakReference<object>(fallbackValue ?? NullValue); }
/// <summary> /// Adds an error to the <see cref="BindingNotification"/>. /// </summary> /// <param name="e">The error to add.</param> /// <param name="type">The error type.</param> public void AddError(Exception e, BindingErrorType type) { Contract.Requires<ArgumentNullException>(e != null); Contract.Requires<ArgumentException>(type != BindingErrorType.None); Error = Error != null ? new AggregateException(Error, e) : e; if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error) { ErrorType = BindingErrorType.Error; } }