Esempio n. 1
0
        /// <summary></summary>
        /// <param name="clss">Class of the custom type</param>
        /// <param name="nDims">number of dimensions. 0 for scalar.</param>
        /// <returns>an instance of the validator</returns>
        public static Validator Get(Type clss, int nDims, bool subclassOk)
        {
            CheckDims(nDims);

            if (nDims > MAX_CACHED)
            {
                return(new Validator_custom(clss, nDims, subclassOk));
            }

            Key       key = new Key(clss, nDims, subclassOk);
            Validator v   = null;

            try
            {
                v = validators[key];
            }
            catch (Exception)
            {
                v = null;
            }

            if (v == null)
            {
                v = new Validator_custom(clss, nDims, subclassOk);
                validators.Add(key, v);
            }

            return(v);
        }
Esempio n. 2
0
        public void Test_custom()
        {
            Test(Validator_custom.Get(typeof(DateTime), 2, false), 2,

                 new DateTime[][] { new DateTime[] { new DateTime(), new DateTime() }, new DateTime[] { new DateTime(), new DateTime() } });
        }