ToDefaultValueAttribute ..
Used to mutate the specified values to the associated DefaultValueAttribute.Value or the type's default value.
Namespace: Dado.ComponentModel.DataMutations
Implements: Dado.ComponentModel.DataMutations.MutationAttribute (in Dado.ComponentModel.Mutations)
[AttributeUsage(AttributeTargets.Property)]
public class ToDefaultValueAttribute : MutationAttributeThe ToDefaultValueAttribute replaces any values that are specified in Values with the associated DefaultValueAttribute.Value or the type's default value.
If no Values are specified, the type's default value will be replaced with the associated DefaultValueAttribute.Value.
| Name | Description |
|---|---|
| ToDefaultValueAttribute(Object[]) | Initializes a new instance of the ToDefaultValueAttribute class. |
| Name | Description |
|---|---|
| Priority | Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. |
| RequiresContext | A flag indicating the attribute requires a non-null MutationContext<T> to perform validation. |
| Values | Gets the values to make default. |
| Name | Description |
|---|---|
| Mutate(Object, IMutationContext) | Mutates the given value according to this MutationAttribute. |
| Mutate(Object, Object, IMutationContext) | Mutates the given value according to this MutationAttribute. |
| MutateValue(Object, IMutationContext) | Implements the mutation logic for this ToDefaultValueAttribute. |
Initializes a new instance of the ToDefaultValueAttribute class.
public ToDefaultValueAttribute(
params object[] values
)- values
- Type: System.Object[]
An array of values that should be made default.
Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. Defaults to 50.
public override int Priority { get; set; } = 50;- Type
- System.Int32
Gets the values to make default.
public IEnumerable<object> Values { get; private set; }- Type
- System.Collections.Generic.IEnumerable<System.Object>
Mutates the given value according to this MutationAttribute.
public object Mutate(
object value,
object defaultValue,
IMutationContext context = null
)The resulting mutated value.
- value
- Type: System.Object
The value to mutate. - defaultValue
- Type: System.Object
The value to be used instead of the type's default value. - context
- Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes thevaluebeing mutated and provides services and context for mutation.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is required and null. |
Implements the mutation logic for this ToDefaultValueAttribute.
protected override object MutateValue(
object value,
IMutationContext context
)The type's default value when the specified value is in Values.
- value
- Type: System.Object
The value to mutate. - context
- Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes thevaluebeing mutated and provides services and context for mutation.