Class BindingCommand<T, TProperty>
Encapsulates a command that binds a property or a field to a value.
Inheritance
Inherited Members
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class BindingCommand<T, TProperty> : ISpecimenCommand, ObsoletedMemberShims.ISpecifiedSpecimenCommand<T>, ISpecifiedSpecimenCommand<T>, IRequestSpecification
Type Parameters
Name | Description |
---|---|
T | The type of the specimen on which the property or value will be set. |
TProperty | The type of property or field. |
Constructors
| Improve this Doc View SourceBindingCommand(Expression<Func<T, TProperty>>)
Initializes a new instance of the BindingCommand<T, TProperty> class with the supplied property picker expression.
Declaration
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies a property or field. |
Remarks
This constructor implies that an anonymous value will be assigned to the property or
field identified by propertyPicker
.
BindingCommand(Expression<Func<T, TProperty>>, TProperty)
Initializes a new instance of the BindingCommand<T, TProperty> class with the supplied property picker expression and the value to be assigned to that property or field.
Declaration
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker, TProperty propertyValue)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies a property or field. |
TProperty | propertyValue | The value to assign to the property or field identified by
|
BindingCommand(Expression<Func<T, TProperty>>, Func<ISpecimenContext, TProperty>)
Initializes a new instance of the BindingCommand<T, TProperty> class with the supplied property picker expression and a function that creates a value to be assigned to that property or field.
Declaration
public BindingCommand(Expression<Func<T, TProperty>> propertyPicker, Func<ISpecimenContext, TProperty> valueCreator)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TProperty>> | propertyPicker | An expression that identifies a property or field. |
System.Func<ISpecimenContext, TProperty> | valueCreator | A function that creates a value that will be assigned to the property or field
identified by |
Properties
| Improve this Doc View SourceMember
Gets the member identified by the expression supplied through the constructor.
Declaration
public MemberInfo Member { get; }
Property Value
Type | Description |
---|---|
System.Reflection.MemberInfo |
ValueCreator
Gets the function that creates a value to be assigned to the property or field identified by Member.
Declaration
public Func<ISpecimenContext, TProperty> ValueCreator { get; }
Property Value
Type | Description |
---|---|
System.Func<ISpecimenContext, TProperty> |
Methods
| Improve this Doc View SourceExecute(T, ISpecimenContext)
Executes the command on the supplied specimen by assigning the property of field the correct value.
Declaration
[Obsolete("This method is no longer used and will be removed in future versions. Please use the Execute(object, ISpecimenContext) overload instead.")]
public void Execute(T specimen, ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
T | specimen | A specimen that should have its property or field assigned. |
ISpecimenContext | context | An ISpecimenContext which can supply an anonymous value for the property or field. |
Remarks
This method assigns a value to the property or field identified by the expression
supplied to the class' constructor. If no value (or creator) was supplied to the
constructor, context
will be used to create the value.
Execute(Object, ISpecimenContext)
Executes the command on the supplied specimen by assigning the property of field the correct value.
Declaration
public void Execute(object specimen, ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | specimen | |
ISpecimenContext | context |
Remarks
This method assigns a value to the property or field identified by
the expression supplied to the class' constructor. If no value (or
creator) was supplied to the constructor,
context
will be used to create the value.
IsSatisfiedBy(Object)
Evaluates whether a request matches the property or field affected by this command.
Declaration
[Obsolete("This method is no longer used and will be removed in future versions. Please use this.Member property for specification instead.")]
public bool IsSatisfiedBy(object request)
Parameters
Type | Name | Description |
---|---|---|
System.Object | request | The specimen request. |
Returns
Type | Description |
---|---|
System.Boolean | true if |