AddInstanceAuthorizationRules & static properties on base types

AddInstanceAuthorizationRules & static properties on base types

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


detritus posted on Saturday, September 27, 2008

Hi,

I've got a couple of properties (for auditing purposes) always same for all BOs in my app so I'm inheriting my BOs from a base one managing these properties (I'm not using any code-gen yet). I copied Rocky's technique to force inherited static properties to register themselves (with the use of static _ForceInit variable). Everything worked great until I decided to override AddInstanceAuthorizationRules method to define instance based rules for my BO.

At this point loading data to inherited properties started to raise exceptions complaining that the properties are not registered. Debuged and see that they're registered just fine but have no index assigned to them. I think (I'm new to CSLA) those indexes are used by managed properties (which I'm using) to access storage in method GetFieldData (FieldDataManager.cs).

More debug revealed that at the time CreateConsolidatedList called (which assignes values to those indexes) my inherited class have not yet register its properties.

In short, I think using any properties on the instance during construction of the BO with inherited managed properties brokes the sequence of property indexing. Is this a bug or am I doing something wrong?

By the way, can I use instance values in method AddInstanceAuthorizationRules in the first place? This method is called from constructor when there is not data to speak of. Am I reading the name of this method wrong?

Sinan

Copyright (c) Marimer LLC