예제 #1
0
        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);
        }
예제 #2
0
 public Validator()
 {
     _TypeValidator  = new SystemTypeValidator <T>();
     _TestValidators = new Dictionary <Type, ITestValidator>();
 }