vendredi 22 septembre 2017

PropertyDescriptor and inheritance

I'm using TypeDescriptor.GetProperties(instance) and it returns me all properties and get/set methods for it from base class.

I have base class:

public class Foo
{
    public virtual string Name
    {
      get => _name;
      set => _name = value;
    }
}

Derrived class:

public class Bar
{
    public override string Name => "Test";
}

When I'm getting info for 'Name' property PropertyDescriptor.IsReadOnly equals to 'false', but it should be 'true'. How can I settup 'PropertyDescriptor' so it would return me data only for derrived class type?





Aucun commentaire:

Enregistrer un commentaire