Skip to content
Michael Ahern edited this page Dec 19, 2013 · 13 revisions

Welcome to the IfInjector wiki. IfInjector is a micro-IoC injector intended for use in mobile (Xamarin /WP7.1+) environments. To simplify this usage the code is packaged as a single PCL for all environments.

The implementation is distinguished from other options by offering auto-wiring capabilities similar to a full IoC framework such as Ninjit, while weighing in at ~40 KB.

Background

The background page, covers the details why I created this project as well as its divergence from fFastInjector. These details are not relevant if you are only looking to get a coding quickstart.

Key Features

  • Auto-Wiring
  • Configuration through code
  • Configuration through attributes
  • Fast (top performer on IoC Container Shootout)
  • Small

Quickstart

The code sample below should give you a flavor of the types of things you can do. A deeper explanation is given in the full documentation.

// =================================
// Setup
// =================================
using IfInjector;

[ImplementedBy(typeof(MyType))]
interface IMyType { }

interface IMyOtherType{}

[Singleton]
class MyType : IMyType {
  
   [Inject]
   public MyType(IMyOtherType myOtherType) {
      MyOtherType = myOtherType;
   }

   public IMyOtherType MyOtherType { get; private set; }

}

[Singleton]
class MyOtherType : IMyOtherType {}

// =================================
// Usage
// =================================
var injector = new Injector();

IMyType obj = injector.Resolve<IMyType>();

Clone this wiki locally