private static IComparable ExtractComparableValue <T>(T value) { if (IsInstanceOfTypeIComparable(value)) { return((IComparable)value); } IComparable comparableValue = null; if (value != null) { T result; SystemTypeValidator <T> .TryChangeType(value, false, out result); if (IsInstanceOfTypeIComparable(result)) { comparableValue = (IComparable)result; } } bool cannotExtractTypeIComparableOfValue = value != null && comparableValue == null; if (cannotExtractTypeIComparableOfValue) { throw new ArgumentException( "Validation cannot determine the IComparable interface associated with value", "value"); } return(comparableValue); }
public Validator() { _TypeValidator = new SystemTypeValidator <T>(); _TestValidators = new Dictionary <Type, ITestValidator>(); }