public override object Clone() { GetterClass obj = new GetterClass(_property); CopyFromThis(obj); return(obj); }
protected override object OnEditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, System.Windows.Forms.Design.IWindowsFormsEditorService service, object value) { IWithProject mc = context.Instance as IWithProject; if (mc != null) { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { GetterClass val = value as GetterClass; System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; DlgMethod dlg = val.CreateMethodEditor(rc); try { dlg.SetNameReadOnly(); dlg.LoadMethod(val, EnumParameterEditType.ReadOnly); dlg.Text = val.ToString(); if (service.ShowDialog(dlg) == DialogResult.OK) { value = val; ILimnorDesignerLoader l = LimnorProject.ActiveDesignerLoader as ILimnorDesignerLoader; if (l != null) { //save the property and hence save the getter DesignUtil.SaveCustomProperty(LimnorProject.ActiveDesignerLoader.Node, l.Writer, val.Property); //save actions List <IAction> actions = val.GetActions(); if (actions != null) { foreach (IAction a in actions) { l.GetRootId().SaveAction(a, l.Writer); } } LimnorProject.ActiveDesignerLoader.NotifyChanges(); } } } catch (Exception err) { MathNode.Log(TraceLogClass.GetForm(provider), err); } finally { val.ExitEditor(); } } } return(value); }
public override CodeExpression GetReferenceCode(IMethodCompile method, CodeStatementCollection statements, bool forValue) { if (Property != null) { bool inside = false; SetterClass sc = method as SetterClass; if (sc != null) { inside = sc.Property.IsSameObjectRef(Property); } else { GetterClass gc = method as GetterClass; if (gc != null) { inside = gc.Property.IsSameObjectRef(Property); } } if (inside) { CodeExpression ownerCode; if (Property.IsStatic) { MathNodePropertyField.CheckDeclareField(Property.IsStatic, Property.FieldMemberName, Property.PropertyType, method.TypeDeclaration, Property.DefaultValue); ownerCode = new CodeTypeReferenceExpression(Property.Holder.TypeString); return(new CodeFieldReferenceExpression(ownerCode, Property.FieldMemberName)); } else { ownerCode = new CodeBaseReferenceExpression(); return(new CodeFieldReferenceExpression(ownerCode, Property.Name)); } } else { Property.SetHolder(Holder); return(Property.GetReferenceCode(method, statements, forValue)); } } return(null); }
public virtual CodeExpression GetReferenceCode(IMethodCompile method, CodeStatementCollection statements, bool forValue) { if (Property != null) { bool isWeb = false; if (this.RootPointer != null) { isWeb = this.RootPointer.IsWebObject; } else if (this.Property.RootPointer != null) { isWeb = this.Property.RootPointer.IsWebObject; } if (isWeb) { if (forValue && Property.RunAt == EnumWebRunAt.Client) { if (this.ObjectType.IsArray) { CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression( new CodeVariableReferenceExpression("clientRequest"), "GetStringArrayValue", new CodePrimitiveExpression(DataPassingCodeName)); return(cmie); } else { CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression( new CodeVariableReferenceExpression("clientRequest"), "GetStringValue", new CodePrimitiveExpression(DataPassingCodeName)); return(cmie); } } } bool inside = false; SetterClass sc = method as SetterClass; if (sc != null) { inside = sc.Property.IsSameObjectRef(Property); } else { GetterClass gc = method as GetterClass; if (gc != null) { inside = gc.Property.IsSameObjectRef(Property); } } if (inside) { CodeExpression ownerCode; MathNodePropertyField.CheckDeclareField(Property.IsStatic, Property.FieldMemberName, Property.PropertyType, method.TypeDeclaration, Property.DefaultValue); if (Property.IsStatic) { ownerCode = new CodeTypeReferenceExpression(Property.Holder.TypeString); } else { ownerCode = new CodeThisReferenceExpression(); } return(new CodeFieldReferenceExpression(ownerCode, Property.FieldMemberName)); } else { Property.SetHolder(_holder); return(Property.GetReferenceCode(method, statements, forValue)); } } return(null); }