Setting AllowNew/Edit/Remove in constructor for CSLA 6 Collection object #2991
Replies: 1 comment 3 replies
-
Requiring a constructor to inject application context would have been a massive breaking change to all business classes in every existing codebase, and so I chose not to go down that path. Instead, I added the I did consider trying to check for alternate constructors, but given that lots of instances are created, I didn't want to add that use of reflection into the create instance process. Not that I did any perf testing, so perhaps that choice was premature optimization. In other words, maybe we could enhance the create instance process to first check for a ctor with parameters, and in that case use DI to inject into the ctor, and if not, then check for Another option may be to make the implementation of The only think I can think of for both these options is that there's some complexity with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In prior versions of CSLA I was able to set the AllowNew, AllowEdit and AllowRemove properties in a collection object within the constructor based on calls to HasPermission. So for example I had code like this:
However, for CSLA 6 the HasPermission method requires the ApplicationContext, and the ApplicationContext doesn't exist in the constructor (unless I'm doing something wrong). So is the work around for this that I now have to set these properties in the Create and Fetch DataPortal methods? Or is it possible to inject the ApplicationContext into the constructor?
Beta Was this translation helpful? Give feedback.
All reactions