Exemplo n.º 1
0
        private string GetFragmentCodegen(ICodegenContext context)
        {
            var msvc = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
            var mtype = context.MakeAddMember(typeof(BeanEventType), _fragmentEventType);

            var block = context.AddMethod(typeof(Object), TargetType, "underlying", this.GetType())
                    .DeclareVar(BeanPropType, "object", CodegenUnderlyingGet(Ref("underlying"), context))
                    .IfRefNullReturnNull("object");

            if (_isArray)
            {
                return block.MethodReturn(StaticMethod(
                    typeof(BaseNativePropertyGetter), "ToFragmentArray",
                    Cast(typeof(Object[]), Ref("object")),
                    Ref(mtype.MemberName),
                    Ref(msvc.MemberName)));
            }
            if (_isIterable)
            {
                return block.MethodReturn(StaticMethod(
                    typeof(BaseNativePropertyGetter), "ToFragmentIterable",
                    Ref("object"),
                    Ref(mtype.MemberName),
                    Ref(msvc.MemberName)));
            }
            return block.MethodReturn(ExprDotMethod(
                Ref(msvc.MemberName), "AdapterForTypedBean",
                Ref("object"),
                Ref(mtype.MemberName)));
        }
Exemplo n.º 2
0
 protected override ICodegenExpression HandleCreateFragmentCodegen(ICodegenExpression value, ICodegenContext context)
 {
     var mSvc = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
     var mType = context.MakeAddMember(typeof(EventType), _fragmentEventType);
     return StaticMethod(typeof(BaseNestableEventUtil), "HandleBNCreateFragmentMap", value,
         Ref(mType.MemberName),
         Ref(mSvc.MemberName));
 }
Exemplo n.º 3
0
        private string GetAvroFragmentCodegen(ICodegenContext context)
        {
            var mSvc  = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
            var mType = context.MakeAddMember(typeof(EventType), _fragmentType);

            return(context.AddMethod(typeof(Object), typeof(GenericRecord), "record", GetType())
                   .DeclareVar(typeof(Object), "value", CodegenUnderlyingGet(Ref("record"), context))
                   .MethodReturn(StaticMethod(GetType(), "GetFragmentAvro", Ref("value"), Ref(mSvc.MemberName), Ref(mType.MemberName))));
        }
        public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression, ICodegenContext context)
        {
            var mSvc  = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
            var mType = context.MakeAddMember(typeof(EventType), _fragmentType);

            return(StaticMethod(typeof(BaseNestableEventUtil), "GetBNFragmentNonPono",
                                CodegenUnderlyingGet(underlyingExpression, context),
                                Ref(mType.MemberName),
                                Ref(mSvc.MemberName)));
        }
Exemplo n.º 5
0
 private string GetFragmentCodegen(ICodegenContext context)
 {
     var mSvc = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
     var mType = context.MakeAddMember(typeof(EventType), _fragmentEventType);
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "value", CodegenUnderlyingGet(Ref("map"), context))
         .IfInstanceOf("value", typeof(EventBean[]))
         .BlockReturn(Ref("value"))
         .MethodReturn(StaticMethod(typeof(BaseNestableEventUtil), "GetBNFragmentArray",
             Ref("value"), Ref(mType.MemberName),
             Ref(mSvc.MemberName)));
 }
 private string GetCodegen(ICodegenContext context)
 {
     var mCache = context.MakeAddMember(typeof(VariantPropertyGetterCache), _propertyGetterCache);
     var mCaster = context.MakeAddMember(typeof(SimpleTypeCaster), _caster);
     return context.AddMethod(typeof(object), typeof(EventBean), "eventBean", GetType())
         .DeclareVar(typeof(object), "value",
             StaticMethod(typeof(VariantEventPropertyGetterAny), "variantGet",
                 Ref("eventBean"), Ref(mCache.MemberName),
                 Constant(_assignedPropertyNumber)))
         .MethodReturn(ExprDotMethod(Ref(mCaster.MemberName), "cast",
             Ref("value")));
 }
 private string GetCodegen(ICodegenContext context)
 {
     var mgetter = context.MakeAddMember(typeof(EventPropertyGetter), _nestedGetter);
     var msvc = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
     return context.AddMethod(typeof(object), typeof(EventBean), "obj", GetType())
         .DeclareVar(typeof(object), "result",
             _revisionGetter.CodegenEventBeanGet(Ref("obj"), context))
         .IfRefNullReturnNull("result")
         .DeclareVar(typeof(EventBean), "theEvent",
             ExprDotMethod(Ref(msvc.MemberName), "adapterForBean",
                 Ref("result")))
         .MethodReturn(ExprDotMethod(Ref(mgetter.MemberName), "get",
             Ref("theEvent")));
 }
Exemplo n.º 8
0
        private String GetCodegen(ICodegenContext context)
        {
            var mComponentType = context.MakeAddMember(typeof(Type), _componentType);
            var mParser        = context.MakeAddMember(typeof(SimpleTypeParser), _parser);

            return(context.AddMethod(typeof(object), typeof(object), "node", GetType())
                   .DeclareVar(typeof(object[]), "result", _getter.GetValueAsNodeArrayCodegen(Ref("node"), context))
                   .IfRefNullReturnNull("result")
                   .MethodReturn(
                       StaticMethod(
                           GetType(), "GetDOMArrayFromNodes",
                           Ref("result"),
                           Ref(mComponentType.MemberName),
                           Ref(mParser.MemberName))));
        }
 public ICodegenExpression CodegenEventBeanGet(ICodegenExpression beanExpression, ICodegenContext context)
 {
     var member = context.MakeAddMember(typeof(RevisionGetterParameters), _parameters);
     return ExprDotMethod(
         Cast(typeof(RevisionEventBeanMerge), beanExpression), "GetVersionedValue",
         Ref(member.MemberName));
 }
Exemplo n.º 10
0
        private String GetValueAsFragmentCodegen(ICodegenContext context)
        {
            var mType = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);

            return(context
                   .AddMethod(typeof(object), typeof(object), "node", GetType())
                   .DeclareVar(typeof(object), "result", GetValueAsNodeCodegen(Ref("node"), context))
                   .IfRefNullReturnNull("result")
                   .MethodReturn(ExprDotMethod(Ref(mType.MemberName), "GetEvent", Ref("result"))));
        }
        private string GetFragmentCodegen(ICodegenContext context)
        {
            var member = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);

            return(context.AddMethod(typeof(object), typeof(XmlNode), "node", GetType())
                   .DeclareVar(typeof(XmlNode), "result",
                               Cast(typeof(XmlNode), CodegenUnderlyingGet(Ref("node"), context)))
                   .IfRefNullReturnNull("result")
                   .MethodReturn(ExprDotMethod(
                                     Ref(member.MemberName), "GetEvent", Ref("result"))));
        }
Exemplo n.º 12
0
        public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression,
                                                            ICodegenContext context)
        {
            if (_fragmentFactory == null)
            {
                return(ConstantNull());
            }

            var mExpression      = context.MakeAddMember(typeof(XPathExpression), _expression);
            var mExpressionText  = context.MakeAddMember(typeof(String), _expressionText);
            var mProperty        = context.MakeAddMember(typeof(String), _property);
            var mFragmentFactory = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);
            var mResultType      = context.MakeAddMember(typeof(XmlQualifiedName), _resultType);

            return(StaticMethod(typeof(XPathPropertyGetter), "evaluateXPathFragment", underlyingExpression,
                                Ref(mExpression.MemberName),
                                Ref(mExpressionText.MemberName),
                                Ref(mProperty.MemberName),
                                Ref(mFragmentFactory.MemberName),
                                Ref(mResultType.MemberName)));
        }
Exemplo n.º 13
0
        private String GetValueAsFragmentCodegen(ICodegenContext context)
        {
            var member = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);

            return(context
                   .AddMethod(typeof(object), typeof(object), "node", GetType())
                   .DeclareVar(typeof(object), "result", StaticMethod(
                                   typeof(DOMIndexedGetter), "GetNodeValue",
                                   Ref("node"),
                                   Constant(_propertyName),
                                   Constant(_index)))
                   .IfRefNullReturnNull("result")
                   .MethodReturn(ExprDotMethod(Ref(member.MemberName), "GetEvent", Ref("result"))));
        }
Exemplo n.º 14
0
        public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression, ICodegenContext context)
        {
            var member = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);

            if (!_isArray)
            {
                return(StaticMethod(GetType(), "GetValueAsNodeFragment", underlyingExpression,
                                    Constant(_propertyName), Ref(member.MemberName)));
            }
            else
            {
                return(StaticMethod(GetType(), "GetValueAsNodeFragmentArray", underlyingExpression,
                                    Constant(_propertyName), Ref(member.MemberName)));
            }
        }
Exemplo n.º 15
0
        public ICodegenExpression CodegenUnderlyingGet(ICodegenExpression underlyingExpression, ICodegenContext context)
        {
            var mExpression         = context.MakeAddMember(typeof(XPathExpression), _expression);
            var mExpressionText     = context.MakeAddMember(typeof(String), _expressionText);
            var mProperty           = context.MakeAddMember(typeof(String), _property);
            var mOptionalCastToType = context.MakeAddMember(typeof(Type), _optionalCastToType);
            var mResultType         = context.MakeAddMember(typeof(XmlQualifiedName), _resultType);
            var mIsCastToArray      = context.MakeAddMember(typeof(bool), _isCastToArray);
            var mSimpleTypeParser   = context.MakeAddMember(typeof(SimpleTypeParser), _simpleTypeParser);

            return(StaticMethod(typeof(XPathPropertyGetter), "evaluateXPathGet", underlyingExpression,
                                Ref(mExpression.MemberName),
                                Ref(mExpressionText.MemberName),
                                Ref(mProperty.MemberName),
                                Ref(mOptionalCastToType.MemberName),
                                Ref(mResultType.MemberName),
                                Ref(mIsCastToArray.MemberName),
                                Ref(mSimpleTypeParser.MemberName)));
        }
 public ICodegenExpression CodegenEventBeanExists(ICodegenExpression beanExpression, ICodegenContext context)
 {
     var member = context.MakeAddMember(typeof(VariantPropertyGetterCache), _propertyGetterCache);
     return StaticMethod(typeof(VariantEventPropertyGetterAny), "variantExists", beanExpression,
         Ref(member.MemberName), Constant(_assignedPropertyNumber));
 }