Skip to content

Dependency Injection #271

Answered by Daniel-Svensson
dsoltesz asked this question in Q&A
Discussion options

You must be logged in to vote

The general approach to implement DI is to implement the IDomainServiceFactory interface.

  • The create method should create a new instance and ensure that it is initialized
  • The release methods should dispose the instance (and any dependencies)

If you need to store some additional state (such as a scope/context that needs to be disposed in the release method) I find that the easiest approach is to add it to a interface that all your services implement.
You might also be able to use OperationContext.Current.Extensions to store additional information

Samples:

If you cr…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Daniel-Svensson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants