Пример #1
0
        protected void SetValue(string lastTokenstring, string lastToken)
        {
            switch (lastTokenstring)
            {
            case "No":
                int intValue = 0;
                Int32.TryParse(lastToken, out intValue);

                this.value = FactValue.Parse(intValue);
                break;

            case "Do":
                double doubleValue = 0.0;
                Double.TryParse(lastToken, out doubleValue);

                this.value = FactValue.Parse(doubleValue);
                break;

            case "Da":
                DateTime dateValue;
                DateTime.TryParseExact(lastToken, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out dateValue);

                this.value = FactValue.Parse(dateValue);
                break;

            case "Url":
                this.value = FactValue.ParseURL(lastToken);
                break;

            case "Id":
                this.value = FactValue.ParseUUID(lastToken);
                break;

            case "Ha":
                this.value = FactValue.ParseHash(lastToken);
                break;

            case "Q":
                this.value = FactValue.ParseDefiString(lastToken);
                break;

            case "L":
            case "M":
            case "U":
            case "C":
                if (this.IsBoolean(lastToken))
                {
                    this.value = string.Equals(lastToken, "false", StringComparison.OrdinalIgnoreCase)? FactValue.Parse(false) : FactValue.Parse(true);
                }
                else
                {
                    Regex regex = new Regex(@"^([""\“])(.*)([""\”]$)");

                    Match match = regex.Match(lastToken);

                    if (match.Success)
                    {
                        string newS = match.Groups[2].Value;
                        this.value = FactValue.ParseDefiString(newS);
                    }
                    else
                    {
                        this.value = FactValue.Parse(lastToken);
                    }
                }
                break;
            }
        }