internal DynamicProperty(DynamicTypeDescriptor descriptor, Type type, object value, string name, Attribute[] attrs) : base(name, attrs) { _descriptor = descriptor; _type = type; Value = value; DefaultValueAttribute def = DynamicTypeDescriptor.GetAttribute <DefaultValueAttribute>(Attributes); if (def == null) { _hasDefaultValue = false; } else { _hasDefaultValue = true; _defaultValue = def.Value; } if (attrs != null) { foreach (Attribute att in attrs) { _attributes.Add(att); } } }
private void AfterNodeSelect(object sender, TreeViewEventArgs e) { DynamicTypeDescriptor dt = new DynamicTypeDescriptor(typeof(TreeNode)); dt.RemoveProperty("Name"); dt.RemoveProperty("ToolTipText"); dt.RemoveProperty("Checked"); dt.RemoveProperty("ContextMenu"); dt.RemoveProperty("ContextMenuStrip"); dt.RemoveProperty("ImageIndex"); dt.RemoveProperty("ImageKey"); dt.RemoveProperty("Index"); dt.RemoveProperty("SelectedImageIndex"); dt.RemoveProperty("SelectedImageKey"); dt.RemoveProperty("StateImageIndex"); dt.RemoveProperty("StateImageKey"); SelectedPropertyPanel.SelectedObject = dt.FromComponent(XMLContent.SelectedNode); }
public DynamicTypeDescriptor FromComponent(object component) { if (component == null) { throw new ArgumentNullException("component"); } if (!_type.IsAssignableFrom(component.GetType())) { throw new ArgumentException(null, "component"); } DynamicTypeDescriptor desc = new DynamicTypeDescriptor(); desc._type = _type; desc.Component = component; // shallow copy on purpose desc._typeConverter = _typeConverter; desc._editors = _editors; desc._defaultEvent = _defaultEvent; desc._defaultProperty = _defaultProperty; desc._attributes = _attributes; desc._events = _events; desc.OriginalProperties = OriginalProperties; // track values List <PropertyDescriptor> properties = new List <PropertyDescriptor>(); foreach (PropertyDescriptor pd in Properties) { DynamicProperty ap = new DynamicProperty(desc, pd, component); properties.Add(ap); } desc.Properties = new PropertyDescriptorCollection(properties.ToArray()); return(desc); }
internal DynamicProperty(DynamicTypeDescriptor descriptor, PropertyDescriptor existing, object component) : this(descriptor, existing.PropertyType, existing.GetValue(component), existing.Name, GetAttributes(existing)) { _existing = existing; }