Mutator ..
Helper class to validate objects, properties, and other values using their associated MutationAttributes and custom mutation as implemented through the IMutableObject interface.
Namespace: Dado.ComponentModel.DataMutations
public static class Mutator| Name | Description |
|---|---|
| Mutate<T>(MutationContext<T>) | Mutates the instance associated with the current context. |
| Mutate<T>(MutationContext<T>, IEnumerable<MutationAttribute>) | Mutates the value or instance associated with the current context and the specified MutationAttributes. |
| Mutate<T>(MutationContext<T>, IEnumerable<MutationAttribute>, T) | Mutates the specified value against the current context and the specified MutationAttributes. |
| Mutate<T>(MutationContext<T>, T) | Mutates the specified instance against the current context. |
| Mutate<T>(MutationContext<T>, T, IEnumerable<MutationAttribute>) | Mutates the specified instance against the current context and the specified MutationAttributes. |
| MutateProperty<T>(MutationContext<T>, PropertyInfo) | Mutates the specified property of the instance associated with the current context. |
| MutateProperty<T, P>(MutationContext<T>, PropertyInfo, P) | Mutates the specified value against the specified property of the instance associated with the current context. |
| MutateProperty<T, P>(MutationContext<T>, Expression<Func<T, P>>) | Mutates the specified property of the instance associated with the current context. |
| MutateProperty<T, P>(MutationContext<T>, Expression<Func<T, P>>, P) | Mutates the specified value against the specified property of the instance associated with the current context. |
Mutates the instance associated with the current context.
public static T Mutate<T>(
this MutationContext<T> context
)
where T : class- T
- The type to consult during mutation.
The object whose value and properties has been modified according to any associated MutationAttributes and IMutableObject implementation.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
Mutates the value or instance associated with the current context and the specified MutationAttributes.
public static T Mutate<T>(
this MutationContext<T> context,
IEnumerable<MutationAttribute> attributes
)- T
- The type to consult during mutation.
The object whose value and/or properties has been modified according to any associated MutationAttributes and IMutableObject implementation.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - attributes
- Type: System.Collections.Generic.IEnumerable<Dado.ComponentModel.DataMutations.MutationAttribute>
The list of MutationAttributes to modify the specified ObjectInstance against.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When T is a value type, context is required, and null; or when context is null. |
| System.ArgumentNullException | When attributes is null. |
When the consulting type, specified by T, is a reference type, the instance and its properties will be mutated. Likewise, only a value type's value will be mutated.
The MutationAttributes specified in attributes will only be used to mutate the specified value or instance. Any properties that are mutated will be mutated according to their respective MutationAttributes.
Mutates the specified value against the current context and the specified MutationAttributes.
public static T Mutate<T>(
this MutationContext<T> context,
IEnumerable<MutationAttribute> attributes,
T value
)
where T : struct- T
- The type to consult during mutation.
The value that has been modified according to any associated MutationAttributes.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - attributes
- Type: System.Collections.Generic.IEnumerable<Dado.ComponentModel.DataMutations.MutationAttribute>
The list of MutationAttributes to modify the specifiedvalueagainst. - value
- Type: `T
The value to be mutated.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is required and null. |
| System.ArgumentNullException | When attributes is null. |
Mutates the specified instance against the current context.
public static T Mutate<T>(
this MutationContext<T> context,
T instance
)
where T : class- T
- The type to consult during mutation.
The object whose value and/or properties has been modified according to any associated MutationAttributes and IMutableObject implementation.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - instance
- Type: `T
The instance to be modified.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When attributes is null. |
Mutates the specified instance against the current context and the specified MutationAttributes.
public static T Mutate<T>(
this MutationContext<T> context,
T instance,
IEnumerable<MutationAttribute> attributes
)
where T : class- T
- The type to consult during mutation.
The object whose value and properties has been modified according to any associated MutationAttributes and IMutableObject implementation.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - instance
- Type: `T
The instance to be modified. - attributes
- Type: System.Collections.Generic.IEnumerable<Dado.ComponentModel.DataMutations.MutationAttribute>
The list of MutationAttributes to modify the specifiedinstanceagainst.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When attributes is null. |
Mutates the specified property of the instance associated with the current context.
public static object MutateProperty<T>(
this MutationContext<T> context,
PropertyInfo property
)
where T : class- T
- The type to consult during mutation.
The property value that has been modified according to any associated MutationAttributes.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - property
- Type: System.Reflection.PropertyInfo
The property info that describes the member to be modified.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When property is null. |
| System.ArgumentException | When the MemberInfo.Name of context is not a valid property. |
Mutates the specified value against the specified property of the instance associated with the current context.
public static P MutateProperty<T, P>(
this MutationContext<T> context,
PropertyInfo property,
P value
)
where T : class- T
- The type to consult during mutation.
- P
- The property type to consult for MutationAttributes.
The value that has been modified according to any MutationAttributes associated with the specified property.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - property
- Type: System.Reflection.PropertyInfo
The property info that describes thevalueto be modified. - value
- Type: `P
The value to be mutated.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When property is null. |
| System.ArgumentException | When the MemberInfo.Name of context is not a valid property. |
Mutates the specified property of the instance associated with the current context.
public static P MutateProperty<T, P>(
this MutationContext<T> context,
Expression<Func<T, P>> property
)
where T : class- T
- The type to consult during mutation.
- P
- The property type to consult for MutationAttributes.
The property value that has been modified according to any associated MutationAttributes.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - property
- Type: System.Linq.Expressions.Expression<System.Func<`T, `P>>
The expression that selects the property to be modified.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When property is null. |
| System.ArgumentException | When the expression doesn't indicate a valid property. |
| System.ArgumentException | When the MemberInfo.Name of context is not a valid property. |
Mutates the specified value against the specified property of the instance associated with the current context.
public static P MutateProperty<T, P>(
this MutationContext<T> context,
Expression<Func<T, P>> property,
P value
)
where T : class- T
- The type to consult during mutation.
- P
- The property type to consult for MutationAttributes.
The value that has been modified according to any MutationAttributes associated with the specified property.
- context
- Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation. - property
- Type: System.Linq.Expressions.Expression<System.Func<`T, `P>>
The expression that selects the property that describes the `value` to be modified. - value
- Type: `P
The value to be mutated.
| Exception | Condition |
|---|---|
| System.ArgumentNullException | When context is null. |
| System.ArgumentNullException | When property is null. |
| System.ArgumentException | When the expression doesn't indicate a valid property. |
| System.ArgumentException | When the MemberInfo.Name of context is not a valid property. |