示例#1
0
        public void SetValue(string identifier, object value)
        {
            string[] suffixes = identifier.Split(':');
            Variable variable = GetOrCreateVariable(suffixes[0]);

            if (suffixes.Length > 1 && variable.Value is SpecialValue)
            {
                SpecialValue specialValue = (SpecialValue)variable.Value;
                string       suffixName;

                if (suffixes.Length > 2)
                {
                    for (int suffixIndex = 1; suffixIndex < (suffixes.Length - 1); suffixIndex++)
                    {
                        suffixName   = suffixes[suffixIndex].ToUpper();
                        specialValue = (SpecialValue)specialValue.GetSuffix(suffixName);
                        if (specialValue == null)
                        {
                            throw new Exception(string.Format("Suffix {0} not found on object {1}", suffixName, variable.Name));
                        }
                    }
                }

                suffixName = suffixes[suffixes.Length - 1].ToUpper();
                if (!specialValue.SetSuffix(suffixName, value))
                {
                    throw new Exception(string.Format("Suffix {0} not found on object {1}", suffixName, variable.Name));
                }
            }
            else
            {
                variable.Value = value;
            }
        }
示例#2
0
        private bool TryParseSuffix(string text)
        {
            Match match = Regex.Match(text, "^([A-Z0-9_\\-]+?):([A-Z0-9_\\-]+?)$", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                var obj = new Expression(match.Groups[1].Value, executionContext).GetValue();
                if (obj is SpecialValue)
                {
                    SpecialValue = (SpecialValue)obj;
                    Suffix       = match.Groups[2].Value.ToUpper();

                    Value = SpecialValue.GetSuffix(Suffix);
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        private bool TryParseSuffix(string text)
        {
            Match match = Regex.Match(text, "^([A-Z0-9_\\-]+?):([A-Z0-9_\\-]+?)$", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                var obj = new Expression(match.Groups[1].Value, executionContext).GetValue();
                if (obj is SpecialValue)
                {
                    SpecialValue = (SpecialValue)obj;
                    Suffix = match.Groups[2].Value.ToUpper();

                    Value = SpecialValue.GetSuffix(Suffix);
                    return true;
                }
            }

            return false;
        }