virtual public bool TryCloneEntry(out object clone) { clone = null; object subClone; if (mObject.TryCloneEntry(out subClone)) { LamdaObjectProperty lprop = new LamdaObjectProperty((LambdaObject)subClone); lprop.MetaData = this.MetaData; clone = lprop; return(true); } return(false); //throw new Exception("The method or operation is not implemented."); }
private void LoadSettings(object obj) { List <ReflectedPropertyBinder> mBinders = new List <ReflectedPropertyBinder>(); if (obj == null) { this.Visible = false; this.SuspendLayout(); //ClearUI(); ClearUI(); mControls.Clear(); this.ResumeLayout(); return; } if (obj is LambdaObject) { LoadSettings((LambdaObject)obj); return; } if (obj is LamdaObjectProperty) { LamdaObjectProperty lambdaprop = (LamdaObjectProperty)obj; this.ApplyMetaDataToType(lambdaprop.GetName(), lambdaprop.GetName(), lambdaprop.MetaData); LoadSettings((LambdaObject)lambdaprop.GetValue()); return; } this.Visible = true; List <Control> temp = new List <Control>(); Type t = obj.GetType(); if (mTypeDescriptions.ContainsKey(t) == false) { mTypeDescriptions[t] = new TypeDescription(t); } mBinders = new List <ReflectedPropertyBinder>(); foreach (PropertyInfo p in mTypeDescriptions[t].mPropertyInfoList) { ReflectedPropertyBinder b = new ReflectedPropertyBinder(obj, p); mBinders.Add(b); } mProps = new List <HighLevelProperty>(); foreach (ReflectedPropertyBinder b in mBinders) { ApplyMetadata(b, t.Name); HighLevelProperty p = GetHighLevelProperty(b, t.Name); if (b.MetaData.ContainsKey("UpdateEvent")) { p.Changed += new HighLevelProperty.HighLevelPropertyEvent(p_Changed); } p.Changed += new HighLevelProperty.HighLevelPropertyEvent(p_AnyChanged); if (b.MetaData.ContainsKey("Ignore") && (bool)(b.MetaData["Ignore"]) == true) { continue; } mProps.Add(p); string bindName; Control c = p.GetEditor(out bindName); if (b.MetaData.ContainsKey("Alias")) { c.Name = b.MetaData["Alias"].ToString(); } else { c.Name = b.GetName(); } //Set editor properties: Type edtiorType = c.GetType(); foreach (string s in b.MetaData.Keys) { if (s.Contains("EditorProperty.")) { string editorProp = s.Replace("EditorProperty.", ""); PropertyInfo editorPropertyInfo = edtiorType.GetProperty(editorProp); object convertedValue = b.MetaData[s]; convertedValue = Convert.ChangeType(convertedValue, editorPropertyInfo.PropertyType); editorPropertyInfo.SetValue(c, convertedValue, null); } } temp.Add(c); } //saving the ui changes for the end. why is this so slow? this.SuspendLayout(); mControls.Clear(); this.AddControls(temp); this.ResumeLayout(); }