Пример #1
0
        static HelperNumEdit()
        {
            if (CheckDigtEmptyString == null)
            {
                NumberFormatInfo numInfo             = XmlFormating.getNumberFormat();// CultureInfo.CurrentCulture.NumberFormat;
                string           escNegativeSign     = Regex.Escape(NegativeSign = numInfo.NegativeSign);
                string           escPositiveSign     = Regex.Escape(PositiveSign = numInfo.PositiveSign);
                string           escDecimalSeparator = Regex.Escape(DecimalSeparator = numInfo.NumberDecimalSeparator);
                string           escGroupSeparator   = Regex.Escape(GroupSeparator = numInfo.NumberGroupSeparator);

                CheckDigtEmptyString = new Regex(
                    "^((" + escNegativeSign + ")|(" + escPositiveSign + ")){0,1}((" + escGroupSeparator + ")|(0))*(" + escDecimalSeparator + "){0,1}((" + escGroupSeparator + ")|(0))*$",
                    RegexOptions.Compiled);
            }
        }
Пример #2
0
        public static object[] parse(string[] arrVals, string[] arrType)
        {
            XmlFormating f = new XmlFormating();

            object[] arr = new object[arrType.Length];
            for (int i = 0; i < arrType.Length; ++i)
            {
                Type type = parse(arrType[i]);
                if (arrVals.Length > i)
                {
                    arr[i] = f.parse(arrVals[i], type);
                }
                else
                {
                    arr[i] = ToolType.getTypeDefaulValue(type);
                }
            }
            return(arr);
        }
Пример #3
0
        public static int[] strToIntArr(string list)
        {
            XmlFormating _format = new XmlFormating();

            string[]   items    = ToolString.trim(ToolString.explodeList(list));
            List <int> valsList = new List <int>();

            foreach (string itm in items)
            {
                if (itm != string.Empty)
                {
                    object obj = _format.parse(itm, typeof(int));
                    if (obj != null)
                    {
                        valsList.Add((int)obj);
                    }
                }
            }
            return(valsList.ToArray());
        }