I'd like to be able to setup my IoC container via an entry-point of the add-in (my understanding is that the AutoOpen of a class implementing IExcelAddIn will be the very first thing to run when Excel loads the add-in)
public class AddIn : IExcelAddIn
{
public void AutoOpen()
{
// Setup my IoC container
myContainer.Register<AwesomeService>.As<IMyService>();
myContainer.Register<GreatLogger>.As<ILog>();
}
}
And then be able to have dependency resolution on any of my Ribbons in the add-in, ideally via constructor injection (*).
[ComVisible(true)]
public class ModelingRibbon : ExcelRibbon
{
public ModelingRibbon(IMyService service, ILog logger)
{
// ...
}
}
(*) Not sure if constructor injection would not be possible... Looks like the Ribbon instance is constructed before the AutoOpen runs, which would invalidate the idea of setting up the container in the AutoOpen.
Anyway, goal is to have an entry point that allows the opportunity to setup an IoC container, and have dependency resolution across the different instances created by the framework.
I'd like to be able to setup my IoC container via an entry-point of the add-in (my understanding is that the
AutoOpenof a class implementingIExcelAddInwill be the very first thing to run when Excel loads the add-in)And then be able to have dependency resolution on any of my Ribbons in the add-in, ideally via constructor injection (*).
(*) Not sure if constructor injection would not be possible... Looks like the Ribbon instance is constructed before the
AutoOpenruns, which would invalidate the idea of setting up the container in theAutoOpen.Anyway, goal is to have an entry point that allows the opportunity to setup an IoC container, and have dependency resolution across the different instances created by the framework.