/*********
 ** Public methods
 *********/
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     if (this.IsNull(value))
         throw new ParameterContractException(parameter, "cannot be null");
     if (this.IsWhitespace(value))
         throw new ParameterContractException(parameter, "cannot be blank or consist entirely of whitespace");
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     if (this.IsNull(value))
         throw new ParameterContractException(parameter, "cannot be null");
     if (this.IsEmpty(value))
         throw new ParameterContractException(parameter, "cannot be an empty enumeration");
 }
 /// <summary>Construct an instance.</summary>
 /// <param name="parameter">The validated parameter.</param>
 /// <param name="error">The brief description of the contract violation.</param>
 public ParameterContractException(ParameterMetadata parameter, string error)
     : this(parameter.TypeName, parameter.MethodName, parameter.Name, error)
 {
 }
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     if (!this.HasType(value, this.Types))
         throw new ParameterContractException(parameter, this.GetError(value.GetType()));
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     if (IsNullOrDefault(value))
         throw new ParameterContractException(parameter, "cannot have the default value");
 }
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="Exception">This exception is always thrown.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     throw new Exception(String.Format("type={0}, method={1}, parameter={2}, value={3}", parameter.TypeName, parameter.MethodName, parameter.Name, value));
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Validate the requirement on a single method parameter or property setter value.</summary>
 /// <param name="parameter">The parameter metadata.</param>
 /// <param name="value">The parameter value.</param>
 /// <exception cref="ParameterContractException">The contract requirement was not met.</exception>
 public void OnParameterPrecondition(ParameterMetadata parameter, object value)
 {
     if (value == null)
         throw new ParameterContractException(parameter, "cannot be null");
 }