protected virtual void GeneratePropertySet(GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop) { object oval = prop.GetValue(Wrapped); if (oval == null || (prop.HasDefault && prop.IsDefaultValue(oval))) { return; } CodeExpression val = ctx.GenerateValue(oval, prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated(Wrapped)); CodeExpression cprop; TypedPropertyDescriptor tprop = prop as TypedPropertyDescriptor; if (tprop == null || tprop.GladeProperty == prop) { cprop = new CodePropertyReferenceExpression(var, prop.Name); } else { cprop = new CodePropertyReferenceExpression(var, tprop.GladeProperty.Name); cprop = new CodePropertyReferenceExpression(cprop, prop.Name); } ctx.Statements.Add(new CodeAssignStatement(cprop, val)); }
internal protected virtual CodeExpression GenerateObjectCreation(GeneratorContext ctx) { if (ClassDescriptor.InitializationProperties != null) { CodeExpression[] paramters = new CodeExpression [ClassDescriptor.InitializationProperties.Length]; for (int n = 0; n < paramters.Length; n++) { PropertyDescriptor prop = ClassDescriptor.InitializationProperties [n]; paramters [n] = ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated(Wrapped)); } return(new CodeObjectCreateExpression(WrappedTypeName.ToGlobalTypeRef(), paramters)); } else { return(new CodeObjectCreateExpression(WrappedTypeName.ToGlobalTypeRef())); } }
protected virtual void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop) { object oval = prop.GetValue (Wrapped); if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval))) return; CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated (Wrapped)); CodeExpression cprop; TypedPropertyDescriptor tprop = prop as TypedPropertyDescriptor; if (tprop == null || tprop.GladeProperty == prop) { cprop = new CodePropertyReferenceExpression (var, prop.Name); } else { cprop = new CodePropertyReferenceExpression (var, tprop.GladeProperty.Name); cprop = new CodePropertyReferenceExpression (cprop, prop.Name); } ctx.Statements.Add (new CodeAssignStatement (cprop, val)); }
internal protected virtual CodeExpression GenerateObjectCreation (GeneratorContext ctx) { if (ClassDescriptor.InitializationProperties != null) { CodeExpression[] paramters = new CodeExpression [ClassDescriptor.InitializationProperties.Length]; for (int n=0; n < paramters.Length; n++) { PropertyDescriptor prop = ClassDescriptor.InitializationProperties [n]; paramters [n] = ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated (Wrapped)); } return new CodeObjectCreateExpression (WrappedTypeName.ToGlobalTypeRef (), paramters); } else return new CodeObjectCreateExpression (WrappedTypeName.ToGlobalTypeRef ()); }