Beispiel #1
0
        protected IValue GetAttributeValueAllowGetter(Context context, String attrName, bool allowGetter)
        {
            GetterMethodDeclaration getter = allowGetter ? declaration.findGetter(context, attrName) : null;

            if (getter != null)
            {
                context = context.newInstanceContext(this, false).newChildContext();
                return(getter.interpret(context));
            }
            else if (getDeclaration().hasAttribute(context, attrName) || "dbId" == attrName)
            {
                IValue result = null;
                if (values.TryGetValue(attrName, out result))
                {
                    return(result);
                }
                else
                {
                    return(NullValue.Instance);
                }
            }
            else if ("text" == attrName)
            {
                return(new TextValue(this.ToString()));
            }
            else
            {
                return(NullValue.Instance);
            }
        }
Beispiel #2
0
        protected IValue GetMemberAllowGetter(Context context, string attrName, bool allowGetter)
        {
            GetterMethodDeclaration getter = allowGetter ? declaration.findGetter(context, attrName) : null;

            if (getter != null)
            {
                context = context.newInstanceContext(this, false).newChildContext(); // mimic method call
                return(getter.interpret(context));
            }
            else
            {
                Object          value = getPropertyOrField(attrName);
                CSharpClassType ct    = new CSharpClassType(value.GetType());
                return(ct.ConvertCSharpValueToPromptoValue(context, value, null));
            }
        }