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

Latest commit

 

History

History
420 lines (302 loc) · 13.7 KB

File metadata and controls

420 lines (302 loc) · 13.7 KB

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

Syntax

public static class Mutator

Methods

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.

Mutate<T>(MutationContext<T>)

Mutates the instance associated with the current context.

Syntax

public static T Mutate<T>(
	this MutationContext<T> context
)
	where T : class
T
The type to consult during mutation.

Returns

The object whose value and properties has been modified according to any associated MutationAttributes and IMutableObject implementation.

Parameters

context
Type: Dado.ComponentModel.DataMutations.MutationContext<`T>
Describes the type of object being mutated and provides services and context for mutation.

Exceptions

Exception Condition
System.ArgumentNullException When context is null.

Mutate<T>(MutationContext<T>, IEnumerable<MutationAttribute>)

Mutates the value or instance associated with the current context and the specified MutationAttributes.

Syntax

public static T Mutate<T>(
	this MutationContext<T> context,
	IEnumerable<MutationAttribute> attributes
)
T
The type to consult during mutation.

Returns

The object whose value and/or properties has been modified according to any associated MutationAttributes and IMutableObject implementation.

Parameters

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.

Exceptions

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.

Remarks

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.

Mutate<T>(MutationContext<T>, IEnumerable<MutationAttribute>, T)

Mutates the specified value against the current context and the specified MutationAttributes.

Syntax

public static T Mutate<T>(
	this MutationContext<T> context,
	IEnumerable<MutationAttribute> attributes,
	T value
)
	where T : struct
T
The type to consult during mutation.

Returns

The value that has been modified according to any associated MutationAttributes.

Parameters

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 value against.
value
Type: `T
The value to be mutated.

Exceptions

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

Mutate<T>(MutationContext<T>, T)

Mutates the specified instance against the current context.

Syntax

public static T Mutate<T>(
	this MutationContext<T> context,
	T instance
)
	where T : class
T
The type to consult during mutation.

Returns

The object whose value and/or properties has been modified according to any associated MutationAttributes and IMutableObject implementation.

Parameters

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.

Exceptions

Exception Condition
System.ArgumentNullException When context is null.
System.ArgumentNullException When attributes is null.

Mutate<T>(MutationContext<T>, T, IEnumerable<MutationAttribute>)

Mutates the specified instance against the current context and the specified MutationAttributes.

Syntax

public static T Mutate<T>(
	this MutationContext<T> context,
	T instance,
	IEnumerable<MutationAttribute> attributes
)
	where T : class
T
The type to consult during mutation.

Returns

The object whose value and properties has been modified according to any associated MutationAttributes and IMutableObject implementation.

Parameters

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 specified instance against.

Exceptions

Exception Condition
System.ArgumentNullException When context is null.
System.ArgumentNullException When attributes is null.

MutateProperty<T>(MutationContext<T>, PropertyInfo)

Mutates the specified property of the instance associated with the current context.

Syntax

public static object MutateProperty<T>(
	this MutationContext<T> context,
	PropertyInfo property
)
	where T : class
T
The type to consult during mutation.

Returns

The property value that has been modified according to any associated MutationAttributes.

Parameters

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.

Exceptions

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.

MutateProperty<T, P>(MutationContext<T>, PropertyInfo, P)

Mutates the specified value against the specified property of the instance associated with the current context.

Syntax

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.

Returns

The value that has been modified according to any MutationAttributes associated with the specified property.

Parameters

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 value to be modified.
value
Type: `P
The value to be mutated.

Exceptions

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.

MutateProperty<T, P>(MutationContext<T>, Expression<Func<T, P>>)

Mutates the specified property of the instance associated with the current context.

Syntax

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.

Returns

The property value that has been modified according to any associated MutationAttributes.

Parameters

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.

Exceptions

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.

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.

Syntax

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.

Returns

The value that has been modified according to any MutationAttributes associated with the specified property.

Parameters

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.

Exceptions

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.