-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the IfFastInjector wiki. IfFastInjector is a micro-IoC injector consisting of two source files (an interface file and an implementation file).
The implementation is distinguished from other options by offering auto-wiring capabilities similar to a full IoC framework such as Ninjit, while being packed into a <1200 lines of code. The framework was written as a portable class library (PCL) using Xamarin, making it suitable (in theory) for Xamarin.IOS and Xamarin.Android development.
While I have padded out the inherited code with quite a few extra unit tests, the framework has yet to be used in anger
So the first question you may be asking is, why another IoC framework? The answer to this is really two fold:
-
Although existing 'micro' IoC frameworks such as SimpleIoC, could get the job done - they were often missing more advanced features around auto-wiring. Having used Guice in the Java world, except for constructor injection. In C#, the frameworks that provided autowiring (such as Ninjit) - had been targetted at the desktop and would require reworking to use in a Mobile environment. Thus, there seemed to be a gap between the Micro and Full IoC containers for use in the mobile space.
-
Being a java developer by trade, an IoC framework seemed like a hairier piece of coding that could help get me into the C# mindset and really learn the edge features of the platform. With those two challenges before me, I set out to write a micro-IoC framework with advanced auto-wiring capabilities.
The code is a fork of the fFastInjector library, which was noted in the IoC framework shootout as being 'the' fastest framework available. In forking the code, I maintained and extended the core Linq-based architecture which was the key to the original frameworks compactness and performance.
The name of the framework is 'IfFastInjector', which stands for 'instance' 'fFastInjector' to denote one of the key architectural differences.
The major divergences are:
-
As noted earlier, the injector object is instance based rather than a static class. You may have as many injector objects as you like and they will all operate independently of each other.
-
Implementation details are abstracted via an interface. This choice results in a slight overhead vs. the fFastInjector, but results in a more explicit code contract.
-
2 source files instead of 1. The code base consists of a separate interface and implementation file. The separation allows the two to be evolved or replaced separately (if you cared too). The interface file is <200 LOC making it very easy to read through to get an understanding of how to use the library.
-
Auto-Injection Capabilities. There is a lot that can be said here, but the key features are:
- Auto-binding / auto-resolve implementations to interfaces
- Auto-wiring private fields.
- Auto-wiring attributes, including attributes with private 'set' methods.