Class PropertySetCommand
Namespace: AutoFixture.Idioms
Assembly: AutoFixture.Idioms.dll
Assigns a value to a property.
public class PropertySetCommand : IGuardClauseCommandInheritance
Implements
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
PropertySetCommand(PropertyInfo, object)
Initializes a new instance of the PropertySetCommand class.
public PropertySetCommand(PropertyInfo propertyInfo, object owner)Parameters
propertyInfo PropertyInfo
The property which should have a value assigned.
owner object
The instance exposing the property.
Remarks
Although the constructor doesn't enforce this, the owner is
expected to expose the property identified by propertyInfo. If not,
the `Object)` method will fail.
Properties
Owner
Gets the owner supplied via the constructor.
public object Owner { get; }Property Value
PropertyInfo
Gets the property supplied via the constructor.
public PropertyInfo PropertyInfo { get; }Property Value
RequestedParameterName
Gets the parameter name of the requested value.
public string RequestedParameterName { get; }Property Value
Remarks
The RequestedParameterName always returns "value".
RequestedType
Gets the type of the requested value.
public Type RequestedType { get; }Property Value
Remarks
The RequestedType property identifies the type of object which should be supplied to
the Object) method - in this case the type of the
PropertyInfo.
Methods
CreateException(string)
Creates an exception which communicates that an error occured for a specific input value.
public Exception CreateException(string value)Parameters
value string
A string representation of the value.
Returns
An exception which communicates the cause of the error.
Remarks
The value is a string representation of the value supplied to the
`Object)` method. Together with the context contained within any
implementation of `IGuardClauseCommand` this value can be used to build an exception message.
CreateException(string, Exception)
Creates an exception which communicates that an error occured for a specific input value.
public Exception CreateException(string value, Exception innerException)Parameters
value string
A string representation of the value.
innerException Exception
The exception that is the cause of the current exception.
Returns
An exception which communicates the cause of the error.
Remarks
The value is a string representation of the value supplied to the
`Object)` method. Together with the context contained within any
implementation of `IGuardClauseCommand` this value can be used to build an exception message.
CreateException(string, string, Exception)
Creates an exception which communicates that an error occured for a specific input value.
public Exception CreateException(string value, string customError, Exception innerException)Parameters
value string
A string representation of the value.
customError string
A custom explanation of the guard clause failure.
innerException Exception
The exception that is the cause of the current exception.
Returns
An exception which communicates the cause of the error.
Remarks
The value is a string representation of the value supplied to the
`Object)` method. Together with the passed customError and context
contained within any implementation of `IGuardClauseCommand` this value can be used to
build an exception message.
Execute(object)
Executes the action with the specified value.
public void Execute(object value)Parameters
value object
The value with wich the action is executed.
Remarks
The value is expected to be compatible with
`RequestedType`. It should be possible to cast the value to the requested type.