private CodegenMethod GetFieldExistsCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(bool), GetType(), codegenClassScope) .AddParam(field.DeclaringType, "und") .Block .DeclareVar<object>("value", Ref("und." + field.Name)) .IfRefNullReturnFalse("value") .MethodReturn(nestedGetter.UnderlyingExistsCodegen(CastRef(nestedGetter.TargetType, "value"), codegenMethodScope, codegenClassScope)); }
private CodegenMethod IsExistsPropertyCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(bool), GetType(), codegenClassScope) .AddParam(typeof(object[]), "array") .Block .DeclareVar<object>("value", ArrayAtIndex(Ref("array"), Constant(propertyIndex))) .IfRefNullReturnFalse("value") .IfInstanceOf("value", typeof(EventBean)) .BlockReturn( entryGetter.EventBeanExistsCodegen( CastRef(typeof(EventBean), "value"), codegenMethodScope, codegenClassScope)) .MethodReturn( entryGetter.UnderlyingExistsCodegen( FlexCast(entryGetter.TargetType, Ref("value")), codegenMethodScope, codegenClassScope)); }
public static CodegenMethod GetBeanArrayValueExistsCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, BeanEventPropertyGetter nestedGetter, int index) { // TBD - array comparisons that need to be fixed return codegenMethodScope .MakeChild(typeof(bool), typeof(BaseNestableEventUtil), codegenClassScope) .AddParam(typeof(object), "value") .Block .IfRefNullReturnFalse("value") .IfConditionReturnConst( Not(ExprDotMethodChain(Ref("value")).Add("GetType").Get("IsArray")), false) .DeclareVar<Array>("asArray", Cast(typeof(Array), Ref("value"))) .IfConditionReturnConst( Relational( ExprDotName(Ref("asArray"), "Length"), LE, Constant(index)), false) .DeclareVar<object>( "arrayItem", ExprDotMethod( Ref("asArray"), "GetValue", Constant(index))) .IfRefNullReturnFalse("arrayItem") .MethodReturn( nestedGetter.UnderlyingExistsCodegen( Cast(nestedGetter.TargetType, Ref("arrayItem")), codegenMethodScope, codegenClassScope)); }