Reputation: 1631
I am using StructureMap, but i think any DI component or should be able to answer this question.
Let me lay out the concern which i think is possible but figured it would be good to talk it out.
Question
After the method in IUser.SetUser(permissions perm, accessRules, rules) gets called lets say in my controller layer. When IUser now gets injected into the lower layers such as command handlers, services, event handlers, etc. that singleton instance will retain the values of the properties set IUser.SetUser(permissions perm, accessRules, rules) was called correct?
it seems like a simple yes from what i believe about DI, but figured i would ask to make sure.
Upvotes: 0
Views: 36
Reputation: 24913
Usually, all instances of objects in web applications are created per one request.
So, if your IUser
has per request lifetime, it'll keep all data during current request.
If you create IUser
as a singleton for whole application, it'll keep data till app pool recycling.
Upvotes: 1