ARTICLE AD BOX
Because of the complexity of the business, my ASP.NET Core Web API has a lot of services to keep the classes clean, and keep the concerns separated. This works well for overall design and unit testing.
With this design, I have one problem/concern/issue, depending on how you look at it. There may already be an established pattern for it, which I may not be aware. So I'm seeking your help.
In my POST requests, I have one parameter, based on that I have to construct a business object. I am not fetching anything from the database. It's just some business logic. Not very complex, but not something I want to repeat multiple times.
This particular object is needed in multiple place through out the lifecycle of my POST.
I can just create it in the controller and pass it around with different service calls and it works. Is there any other solution. To me it looks like a dependency which I should be able to inject. But I can't register it with the IoC, because it's based on the parameter that will only be known at runtime.
It's like a combination of these two problems (if I can call it a problem in first place).
How to store temporary data for ASP.NET Web API?
Dependency Injection for Long-Lived Objects in Web API?
To explain it a bit further, let's say body of post contains UserName. Based on that UserName, I create a dictionary which is used by in different places/services.
