コード例 #1
0
        protected override object getValueBody(OgnlContext context, object source) // throws OgnlException
        {
            IDictionary answer;

            if (className == null)
            {
                try {
                    answer = (IDictionary)DEFAULT_MAP_CLASS.GetConstructor(new Type[0]).Invoke(new object[0]);
                } catch (Exception ex) {
                    /* This should never happen */
                    throw new OgnlException("Default IDictionary class '" + DEFAULT_MAP_CLASS.Name + "' instantiation error", ex);
                }
            }
            else
            {
                try {
                    answer = (IDictionary)OgnlRuntime.classForName(context, className).GetConstructor(new Type[0]).Invoke(new object[0]);
                } catch (Exception ex) {
                    throw new OgnlException("IDictionary implementor '" + className + "' not found", ex);
                }
            }

            for (int i = 0; i < jjtGetNumChildren(); ++i)
            {
                ASTKeyValue kv = (ASTKeyValue)children[i];
                Node        k  = kv.getKey(),
                            v  = kv.getValue();

                answer.Add(k.getValue(context, source), (v == null) ? null : v.getValue(context, source));
            }
            return(answer);
        }
コード例 #2
0
        public override string ToString()
        {
            string result = "#";

            if (className != null)
            {
                result = result + "@" + className + "@";
            }
            result = result + "{ ";
            for (int i = 0; i < jjtGetNumChildren(); ++i)
            {
                ASTKeyValue kv = (ASTKeyValue)children[i];

                if (i > 0)
                {
                    result = result + ", ";
                }
                result = result + kv.getKey() + " : " + kv.getValue();
            }
            return(result + " }");
        }