In my case I am using Castle Windsor as my IoC container.
I would like to declare a component, where one of the constructor arguments will be set to an existing object at runtime, rather than having the IoC container create the object when it creates the component. For example, the instance of my application's main form.
I suspect there are two approaches:
- Create the object via the container for the first time, then configure it with any necessary runtime values so that when the component later on asks Windsor for it, it is ready to use.
- Create an
IFormProvider
and concreteFormProvider
, where the component requires anIFormProvider
value to be injected, which it subsequently asks for the form instance (i.e.formProvider.Form
).
Any advance on this?