Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a fundamental issue here in that you are giving out a descriptor for the <em>actual</em> object (<code>ExtensionModel</code>), but the combo-box only knows about the wrapper (<code>DynamicClass&lt;T&gt;</code>), so will be trying to invoke methods on the wrong object. You can avoid this by wrapping the descriptors in something that swaps the object for you; such as:</p> <pre><code>class IndirectDescriptor : PropertyDescriptorDecorator { private readonly object instance; public IndirectDescriptor(PropertyDescriptor tail, object instance) : base(tail) { this.instance = instance; } protected override object GetComponent(object component) { return instance; } } abstract class PropertyDescriptorDecorator : PropertyDescriptor { private readonly PropertyDescriptor tail; static Attribute[] GetAttributes(AttributeCollection attribs) { var arr = new Attribute[attribs.Count]; attribs.CopyTo(arr, 0); return arr; } public PropertyDescriptorDecorator(PropertyDescriptor tail) : base(tail.Name, GetAttributes(tail.Attributes)) { this.tail = tail; } protected virtual object GetComponent(object component) { return component; } public override void AddValueChanged(object component, EventHandler handler) { tail.AddValueChanged(GetComponent(component), handler); } public override void RemoveValueChanged(object component, EventHandler handler) { tail.RemoveValueChanged(GetComponent(component), handler); } public override bool CanResetValue(object component) { return tail.CanResetValue(GetComponent(component)); } public override TypeConverter Converter { get { return tail.Converter; } } public override string Category { get { return tail.Category; } } public override Type ComponentType { get { return tail.ComponentType; } } public override string Description { get { return tail.Description; } } public override bool DesignTimeOnly { get { return tail.DesignTimeOnly; } } public override AttributeCollection Attributes { get { return tail.Attributes; } } public override string DisplayName { get { return tail.DisplayName; } } public override PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter) { return tail.GetChildProperties(GetComponent(instance), filter); } public override object GetEditor(Type editorBaseType) { return tail.GetEditor(editorBaseType); } public override object GetValue(object component) { return tail.GetValue(GetComponent(component)); } public override void SetValue(object component, object value) { tail.SetValue(GetComponent(component), value); } public override bool IsBrowsable { get { return tail.IsBrowsable; } } public override bool IsLocalizable { get { return tail.IsLocalizable; } } public override bool IsReadOnly { get { return tail.IsReadOnly; } } public override string Name { get { return tail.Name; } } public override Type PropertyType { get { return tail.PropertyType; } } public override void ResetValue(object component) { tail.ResetValue(GetComponent(component)); } public override bool SupportsChangeEvents { get { return tail.SupportsChangeEvents; } } public override bool ShouldSerializeValue(object component) { return tail.ShouldSerializeValue(GetComponent(component)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload