private string GetCodegen(ICodegenContext context) { return context.AddMethod(typeof(object), typeof(EventBean), "theEvent", GetType()) .DeclareVarWCast(typeof(DecoratingEventBean), "wrapperEvent", "theEvent") .DeclareVar(typeof(Map), "map", ExprDotMethod(Ref("wrapperEvent"), "getDecoratingProperties")) .MethodReturn(_mapGetter.CodegenUnderlyingGet(Ref("map"), context)); }
public static string From( ICodegenContext context, Type expectedUnderlyingType, EventPropertyGetterSPI innerGetter, AccessType accessType, Type generator) { var block = context.AddMethod(accessType == AccessType.EXISTS ? typeof(bool) : typeof(object), typeof(object), "value", generator) .IfNotInstanceOf("value", expectedUnderlyingType) .IfInstanceOf("value", typeof(EventBean)) .DeclareVarWCast(typeof(EventBean), "bean", "value"); switch (accessType) { case AccessType.GET: block = block.BlockReturn(innerGetter.CodegenEventBeanGet(Ref("bean"), context)); break; case AccessType.EXISTS: block = block.BlockReturn(innerGetter.CodegenEventBeanExists(Ref("bean"), context)); break; case AccessType.FRAGMENT: block = block.BlockReturn(innerGetter.CodegenEventBeanFragment(Ref("bean"), context)); break; default: throw new UnsupportedOperationException("Invalid access type " + accessType); } block = block.BlockReturn(Constant(accessType == AccessType.EXISTS ? (object)false : null)); ICodegenExpression expression; switch (accessType) { case AccessType.GET: expression = innerGetter.CodegenUnderlyingGet(Cast( expectedUnderlyingType, Ref("value")), context); break; case AccessType.EXISTS: expression = innerGetter.CodegenUnderlyingExists(Cast( expectedUnderlyingType, Ref("value")), context); break; case AccessType.FRAGMENT: expression = innerGetter.CodegenUnderlyingFragment( Cast(expectedUnderlyingType, Ref("value")), context); break; default: throw new UnsupportedOperationException("Invalid access type " + accessType); } return(block.MethodReturn(expression)); }
private string GetCodegen(ICodegenContext context) { return(context .AddMethod(typeof(object), typeof(XmlNode), "node", GetType()) .DeclareVar(typeof(object), "value", _getter.CodegenUnderlyingGet(Ref("node"), context)) .MethodReturn(StaticMethod(GetType(), "GetXPathNodeListWCheck", Ref("value"), Constant(_index)))); }