Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Latest commit

 

History

History
164 lines (109 loc) · 4.26 KB

File metadata and controls

164 lines (109 loc) · 4.26 KB

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)

Syntax

[AttributeUsage(AttributeTargets.Property)]
public class ToDefaultValueAttribute : MutationAttribute

Remarks

The 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.

Constructors

Name Description
ToDefaultValueAttribute(Object[]) Initializes a new instance of the ToDefaultValueAttribute class.

Properties

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.

Methods

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.

ToDefaultValueAttribute(Object[])

Initializes a new instance of the ToDefaultValueAttribute class.

Syntax

public ToDefaultValueAttribute(
	params object[] values
)

Parameters

values
Type: System.Object[]
An array of values that should be made default.

Priority

Gets or sets a value indicating the priority that determines the order in which MutationAttributes are evaluated. Defaults to 50.

Syntax

public override int Priority { get; set; } = 50;
Type
System.Int32

Values

Gets the values to make default.

Syntax

public IEnumerable<object> Values { get; private set; }
Type
System.Collections.Generic.IEnumerable<System.Object>

Mutate(Object, Object, IMutationContext)

Mutates the given value according to this MutationAttribute.

Syntax

public object Mutate(
	object value,
	object defaultValue,
	IMutationContext context = null
)

Returns

The resulting mutated value.

Parameters

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 the value being mutated and provides services and context for mutation.

Exceptions

Exception Condition
System.ArgumentNullException When context is required and null.

MutateValue(Object, IMutationContext)

Implements the mutation logic for this ToDefaultValueAttribute.

Syntax

protected override object MutateValue(
	object value,
	IMutationContext context
)

Returns

The type's default value when the specified value is in Values.

Parameters

value
Type: System.Object
The value to mutate.
context
Type: Dado.ComponentModel.DataMutations.IMutationContext
Describes the value being mutated and provides services and context for mutation.