public override string ToString()
 {
     return(type.ToString());
 }
Esempio n. 2
0
        private void GetNumber(string expression)
        {
            expression = expression.Trim();
            if (expression == functionType.ToString())
            {
                characterNumbers = -1;
                return;
            }
            if (!expression.ToUpper().StartsWith(functionType.ToString() + "("))
            {
                throw new VNRException(ExceptionType.FRAMEWORK, "Can't get number!");
            }
            int index = expression.IndexOf(')');

            if (index == -1)
            {
                throw new VNRException(ExceptionType.FRAMEWORK, "Can't get number!");
            }
            string result = expression.Substring(functionType.ToString().Length + 1, index - functionType.ToString().Length - 1);

            try
            {
                string[] splits = result.Split(',');

                if (functionType == FunctionTypes.OBJECT)
                {
                    if (splits.Count() >= 6)
                    {
                        //Đủ 6 tham số (table, field, startIndex, length, allowZero, fromlast)
                        objectTabledName = splits[0].Trim();
                        objectFieldName  = splits[1].Trim();
                        startIndex       = int.Parse(splits[2].Trim());
                        characterNumbers = int.Parse(splits[3].Trim());
                        allowZero        = int.Parse(splits[4].Trim()) == 1;
                        fromLast         = int.Parse(splits[5].Trim()) == 1;
                    }
                    else if (splits.Count() >= 5)
                    {
                        objectTabledName = splits[0].Trim();
                        objectFieldName  = splits[1].Trim();
                        startIndex       = int.Parse(splits[2].Trim());
                        characterNumbers = int.Parse(splits[3].Trim());
                        allowZero        = int.Parse(splits[4].Trim()) == 1;
                    }
                    else if (splits.Count() >= 4)
                    {
                        objectTabledName = splits[0].Trim();
                        objectFieldName  = splits[1].Trim();
                        startIndex       = int.Parse(splits[2].Trim());
                        characterNumbers = int.Parse(splits[3].Trim());
                    }
                }
                else
                {
                    if (splits.Count() > 0)
                    {
                        characterNumbers = int.Parse(splits[0].Trim());
                    }
                    if (splits.Count() > 1)
                    {
                        allowZero = int.Parse(splits[1].Trim()) == 1;
                    }
                    if (splits.Count() > 2)
                    {
                        fromLast = int.Parse(splits[2].Trim()) == 1;
                    }
                }
            }
            catch
            {
                throw new VNRException(ExceptionType.FRAMEWORK, "Can't get number!");
            }
        }