Editar

Compartilhar via


ObservableValidator.TrySetProperty Method

Definition

Overloads

TrySetProperty<T>(T, T, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, String) is called, otherwise no state change is performed.

TrySetProperty<T>(T, T, Action<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, Action<T>, String) is called, otherwise no state change is performed.

TrySetProperty<T>(T, T, IEqualityComparer<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, IEqualityComparer<T>, String) is called, otherwise no state change is performed.

TrySetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, String) is called, otherwise no state change is performed.

TrySetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String) is called, otherwise no state change is performed.

TrySetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String) is called, otherwise no state change is performed.

TrySetProperty<T>(T, T, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<T> (ref T field, T newValue, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default);
member this.TrySetProperty : 'T * 'T * IReadOnlyCollection * string -> bool
Protected Function TrySetProperty(Of T) (ByRef field As T, newValue As T, ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

field
T

The field storing the property's value.

newValue
T

The property's value after the change occurred.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to

TrySetProperty<T>(T, T, Action<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, Action<T>, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<T> (T oldValue, T newValue, Action<T> callback, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default);
member this.TrySetProperty : 'T * 'T * Action<'T> * IReadOnlyCollection * string -> bool
Protected Function TrySetProperty(Of T) (oldValue As T, newValue As T, callback As Action(Of T), ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

callback
Action<T>

A callback to invoke to update the property value.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to

TrySetProperty<T>(T, T, IEqualityComparer<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, IEqualityComparer<T>, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<T> (ref T field, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default);
member this.TrySetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * IReadOnlyCollection * string -> bool
Protected Function TrySetProperty(Of T) (ByRef field As T, newValue As T, comparer As IEqualityComparer(Of T), ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

field
T

The field storing the property's value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to

TrySetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<T>(T, T, IEqualityComparer<T>, Action<T>, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<T> (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, Action<T> callback, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default);
member this.TrySetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * Action<'T> * IReadOnlyCollection * string -> bool
Protected Function TrySetProperty(Of T) (oldValue As T, newValue As T, comparer As IEqualityComparer(Of T), callback As Action(Of T), ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

T

The type of the property that changed.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

callback
Action<T>

A callback to invoke to update the property value.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to

TrySetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<TModel,T>(T, T, TModel, Action<TModel,T>, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<TModel,T> (T oldValue, T newValue, TModel model, Action<TModel,T> callback, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default) where TModel : class;
member this.TrySetProperty : 'T * 'T * 'Model * Action<'Model, 'T (requires 'Model : null)> * IReadOnlyCollection * string -> bool (requires 'Model : null)
Protected Function TrySetProperty(Of TModel As Class, T As Class) (oldValue As T, newValue As T, model As TModel, callback As Action(Of TModel, T), ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

TModel

The type of model whose property (or field) to set.

T

The type of property (or field) to set.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

model
TModel

The model

callback
Action<TModel,T>

The callback to invoke to set the target property value, if a change has occurred.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to

TrySetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, IReadOnlyCollection<ValidationResult>, String)

Tries to validate a new value for a specified property. If the validation is successful, SetProperty<TModel,T>(T, T, IEqualityComparer<T>, TModel, Action<TModel,T>, String) is called, otherwise no state change is performed.

protected bool TrySetProperty<TModel,T> (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> comparer, TModel model, Action<TModel,T> callback, out System.Collections.Generic.IReadOnlyCollection<System.ComponentModel.DataAnnotations.ValidationResult> errors, string? propertyName = default) where TModel : class;
member this.TrySetProperty : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> * 'Model * Action<'Model, 'T (requires 'Model : null)> * IReadOnlyCollection * string -> bool (requires 'Model : null)
Protected Function TrySetProperty(Of TModel As Class, T As Class) (oldValue As T, newValue As T, comparer As IEqualityComparer(Of T), model As TModel, callback As Action(Of TModel, T), ByRef errors As IReadOnlyCollection(Of ValidationResult), Optional propertyName As String = Nothing) As Boolean

Type Parameters

TModel

The type of model whose property (or field) to set.

T

The type of property (or field) to set.

Parameters

oldValue
T

The current property value.

newValue
T

The property's value after the change occurred.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> instance to use to compare the input values.

model
TModel

The model

callback
Action<TModel,T>

The callback to invoke to set the target property value, if a change has occurred.

errors
IReadOnlyCollection<ValidationResult>

The resulting validation errors, if any.

propertyName
String

(optional) The name of the property that changed.

Returns

Whether the validation was successful and the property value changed as well.

Applies to