In my case, I use Castle Windsor as my IoC container.
I would like to declare a component when one of the constructor arguments is set to an existing object at runtime, instead of the IoC container creating the object when it was created. For example, an instance of the main form of my application.
I suspect there are two approaches:
- Create the object through the container for the first time, then configure it with any necessary runtime values so that when the component later asks for Windsor from it, it is ready to use.
- Create an
IFormProvider and a specific FormProvider where the component requires an IFormProvider value, which then requests an instance of the form (i.e. formProvider.Form ).
Any progress on this?
source share