Exemple #1
0
        public object Evaluate(IInterpretContext ctx)
        {
            try {
                string completeKey = ObjectName;
                if (this.Properties != null)
                {
                    foreach (string property in Properties)
                    {
                        completeKey += "." + property;
                    }
                }

                Object obj = ctx.Bag.ContainsKey(completeKey)
                                        ? ctx.Bag[completeKey]
                                        : null;

                if (obj == null)
                {
                    try {
                        string key = this.ObjectName;
                        obj = ctx.Bag.ContainsKey(key) ? ctx.Bag[key] : null;
                        if (obj != null)
                        {
                            obj = reflector.Eval(obj, this.Properties);
                        }
                    }
                    catch (Exception ex) {
                        throw new Exception(
                                  "An error occurred looking up key " + completeKey,
                                  ex
                                  );
                    }
                }

                // loop through all the attributes and process them against the obj
                if (this.Attributes != null)
                {
                    obj = filterRunner.RunFilters(obj, this.Attributes, ctx.Bag, this);
                }

                return(obj);
            }
            catch (Exception ex) {
                Trace.WriteLine(ex.ToString());
                throw;
            }
        }