"Untidy" Options for CanReadProperty and CanWriteProperty

"Untidy" Options for CanReadProperty and CanWriteProperty

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

JonStonecash posted on Tuesday, July 06, 2010


My team is in the process of implementing a claims-based authorization setup.  This means that we are calling CanReadProperty and CanWriteProperty a great deal.  The standard CSLA (Beta 3 of CSLA 4) offers two choices to identity the property: a string containing the name of the property and the property info object.  We do not want to use strings (for all sorts of reasons including typos and the lack of refactoring) and we would prefer to not expose the property info fields.  We would like to see CanXXXProperty methods that take an expression, similar to the functionality for registering the property in the first place.

I hope that this is not too late to get into the final CSLA 4.


Jon Stonecash


RockfordLhotka replied on Tuesday, July 06, 2010

You should expose the PropertyInfo<T> fields as public.

This is a recommended best practice for CSLA 4, and is basically required for any SL4 work.

But it also matches the normal declaration and usage of dependency properties, on which CSLA properties are modeled. The whole point of having the metadescriptors (the PropertyInfo<T> fields) is to allow the application to make use of that metadata without resorting to reflection.

Accepting an expression would require a reflection call every time, which is just not elegant, and will have a perf impact if it is used frequently - and you indicate that it would be used frequently.

But ultimately, the recommended practice in CSLA 4 is to make the PropertyInfo<T> fields public.

  1. This follows the common dependency property model
  2. It allows use of the metadata by an external DAL (like an object factory)
  3. It allows the use of the metadata by other app code (like the UI)
  4. It is required for SL4 apps, so CSLA can auto-initialize the static fields before deserialization


JonStonecash replied on Tuesday, July 06, 2010

Thanks.  A version of the application in SL4 is not planned at this time but is a distinct possibility.  Public, it is.

Copyright (c) Marimer LLC