I have a user class that is created at run-time in my business layer and has methods like AddPrefrence, CreateItem and delete. These methods require accesses to a repository. To eliminate dependency I have used the DI container unity to inject the repository in other parts of the application but here I have become a bit stuck as i have to pass in the user info that is only available at run-time. I think there are ways to pass a run-time parameter in unity but this seems like a bit of a code smell, i have also considered an abstract factory but it seems like a bit overkill as this is the only concrete class it will actually have to create. I have also thought about using a different sort of injection, property injection for example.
Is there a clear answer to this problem and could you please give the advantages and disadvantage of the solution or pattern you suggest. Thank you very much.
Aucun commentaire:
Enregistrer un commentaire