コード例 #1
0
        //Validate missVal. It must be a comma delimited list of values convertable to FieldDataType.
        //An item in the list might possibly be in format "x thru y" where x and y must be convertable
        //with x <= y.
        private void CheckMissVal(string valueToCheck, FieldDataType fdt)
        {
            //Check MissVal by attempting to create a RangeList object.
            RangeList throwaway = new RangeList(valueToCheck, fdt);



            ////create a string array containing the comma delimited items
            //string[] listItems = valueToCheck.Split(new char[] { ',' });

            ////validate each item
            //foreach (string sItem in listItems)
            //{
            //    //create a string array by splitting each item on the string "thru"
            //    string[] splitItem = sItem.ToLower().Split(new string[] { "thru" }, StringSplitOptions.None);

            //    //throw an exception if splitting results in more that 2 elements
            //    if (splitItem.Length > 2)
            //    {
            //        throw new ArgumentException("missVal not valid.");
            //    }

            //    foreach (string s in splitItem)
            //    {
            //        CheckType(s, fdt);
            //    }

            //    //verify that x <= y
            //    if (splitItem.Length == 2)
            //    {
            //        switch (fdt)
            //        {
            //            case FieldDataType.DATE:
            //                if (!(DateTime.Parse(splitItem[0]) <= DateTime.Parse(splitItem[1])))
            //                {
            //                    throw new ArgumentException("missVal not valid.");
            //                }
            //                break;

            //            case FieldDataType.FLOAT:
            //                if (!(float.Parse(splitItem[0]) <= float.Parse(splitItem[1])))
            //                {
            //                    throw new ArgumentException("missVal not valid.");
            //                }
            //                break;

            //            case FieldDataType.INT:
            //                if (!(int.Parse(splitItem[0]) <= int.Parse(splitItem[1])))
            //                {
            //                    throw new ArgumentException("missVal not valid.");
            //                }
            //                break;

            //            case FieldDataType.TEXT:
            //                // nothing to check
            //                break;

            //            default:
            //                throw new Exception("FieldDataType invalid.");

            //        }
            //    }
            //}
        }