public static void Validate(this IConstrainedInt val, string arg)
 {
     if (val == null || !val.CheckRange())
     {
         throw new ArgumentException(arg);
     }
 }
        public static bool CheckRange(this IConstrainedInt val)
        {
            int value = val.Value;

            return(value >= val.Min && value <= val.Max);
        }
 public static int ValueOrDefault(this IConstrainedInt val)
 {
     return((val != null) ? val.Value : default(int));
 }