コード例 #1
0
        // Aware of suffixed digits
        public object Lookup(string name)
        {
            // First try the whole thing
            object value = LookupDefaulted <object>(name, null);

            if (value != null)
            {
                return(value);
            }

            if (!name.StartsWith("%"))
            {
                throw new Exception(name + " not found");
            }

            // Does this have suffixes?
            string[] parts = name.Split(':');
            if (parts.Length == 1)
            {
                throw new Exception(name + " not found");
            }

            string   front    = parts[0];
            Variable variable = LookupDefaulted <Variable>(front, null);

            if (variable == null)
            {
                throw new Exception(front + " not found");
            }

            StringBuilder declinedName = new StringBuilder();

            declinedName.Append(front);
            for (int ii = 1; ii < parts.Length; ii++)
            {
                IDeclination declination = LookupDefaulted <IDeclination>(":" + parts[ii], null);
                if (declination == null)
                {
                    throw new Exception(":" + parts[ii] + " not found");
                }

                declinedName.Append(":" + parts[ii]);
                variable = new DeclinedVariable(declinedName.ToString(), variable, declination);
            }

            return(variable);
        }
コード例 #2
0
 public DeclinedVariable(string name, Variable variable, IDeclination declination)
     : base(name)
 {
     this.variable    = variable;
     this.declination = declination;
 }