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