Runar Ovesen Hjerpbakk

Software Philosopher

FermiContainer - an IoC container for the rest of us

Fermicontainer icon

What the world needs most is more IoC containers in the .Net space.

So I created FermiContianer, the simples IoC container imaginable.

It supports registering implementations of interface using either a default constructor or a factory method.

 IFermiContainer fermiContainer = new FermiContainer();
fermiContainer.Register<ICalculator, Calculator
  >(); fermiContainer.Register<ClassWithOutAnInterface

Resolve gives you a new instance each time.

 var calculator = fermiContainer.Resolve<ICalculator
      >(); Assert.IsInstanceOf<Calculator
        >(calculator); var calculator2 = fermiContainer.Resolve<ICalculator
          >(); Assert.AreNotSame(calculator, calculator2); 

Singleton will return the same instance.

 var calculator =
            >(); var calculator2 = fermiContainer.Singleton<ICalculator
              >(); Assert.AreSame(calculator, calculator2); 

That's it! Available through NuGet for for .Net 4.0 or later, Xamarin.iOS, Xamarin.Mac, Xamarin.Android, Windows 8, Windows Phone 8, Windows Store apps and Silverlight 5. The source lives on GitHub.

If FermiContainer ever becomes too simple for your needs, I recommend LightInject.