2

I am exploring TinyIOC as part of learning the IoC concept. I have the basics down but I was wondering, when having multiple project in a solution, if I could do the bootstrapping for the relevant classes in their own project (passing the ioc container to a boostrapper class in each individual project).

Currently I have a console app for testing. It contains the following bootstrapper, which registers all relevant classes from two other projects in the solution:

namespace ConsoleTest
{
public static class Bootstrapper
{
    public static void Register()
    {
        var container = TinyIoCContainer.Current;

        //Appname.Models
        container.Register<IScheduleBuilder, ScheduleBuilder>();
        container.Register<ReviewSetup>();
        container.Register<ReviewSetupConfiguration>();

        //Appname.Data
        container.Register<IRepository<ReviewSetup>>(new ReviewSetupRepository());
    }
}
}

Would it be possible to do something like this:

namespace ConsoleTest
{
public static class Bootstrapper
{
    public static void Register()
    {
        var container = TinyIoCContainer.Current;

        Appname.Models.Bootstrapper.Register(container);
        Appname.Data.Bootstrapper.Register(container);
    }
}
}

Is this approach a) valid in general when applying IoC and b) possible with TinyIOC. So far I have not gotten it to function like this...

Thanks!

Corstiaan
  • 1,114
  • 15
  • 34

0 Answers0