CanEditObject() on instance base?

CanEditObject() on instance base?

Old forum URL: forums.lhotka.net/forums/t/491.aspx


burmajam posted on Wednesday, June 28, 2006

Hi all

I was wondering how CanEditObject() and CanWriteProperty() can have different behaviors based upon some instance criteria (for example... CanWriteProperty = !this.ReadOnly)? It is possible to check that in property setter and throw exception there, but it would be nice if ReadWriteAuthorization class could check that also and make GUI control enabled/disabled.

Any workarounds?

RockfordLhotka replied on Wednesday, June 28, 2006

The CanReadProperty() and CanWriteProperty() methods can be overridden, allowing you to customize behavior if needed.

burmajam replied on Thursday, June 29, 2006

Tnx Rocky for the reply.

One more question. Should I place also attribute like this?

[EditorBrowsable(EditorBrowsableState.Advanced)]
public override bool CanWriteProperty(string propertyName)


RockfordLhotka replied on Thursday, June 29, 2006

Probably. I guess it depends on whether you want the method to appear in most cases. Honestly, in C#, this attribute is almost useless because most people have VS set to show advanced members... But it is a best practice, because VB has a more sophisticated way of showing advanced members in intellisense, and you never know what the C# team might do in the future as well.
 
Rocky

Copyright (c) Marimer LLC