Spring.AutoRegistration: Fluent Configuration for Spring .NET

Spring.AutoRegistration is Fluent registration for Spring .NET, that I ported, inspired by the Unity AutoRegistration.


Here are some examples:

Scans all assemblies that the starts with Spring.AutoRegistration.Test:


var context = new GenericApplicationContext();
            context.Configure()
                .IncludeAssembly(x => x.FullName.StartsWith("Spring.AutoRegistration.Test"))
                .Include(x => x.ImplementsITypeName(), Then.Register())
                .ApplyAutoRegistration();


Registers instances as singleton. You may also use the UsingPrototype method.

var context = new GenericApplicationContext();
            context.Configure()
                .IncludeAssembly(x => x.FullName.StartsWith("Spring.AutoRegistration.Test"))
                .Include(x => x.ImplementsITypeName(), Then.Register().UsingSingleton())
                .ApplyAutoRegistration();


Injects properties using InjectAttribute:

var context = new GenericApplicationContext();
            context.Configure()
                .IncludeAssembly(x => x.FullName.StartsWith("Spring.AutoRegistration.Test"))
                .Include(x => x.ImplementsITypeName(), Then.Register().UsingSingleton()
                           .InjectByProperty(If.DecoratedWith<InjectAttribute>))
                .ApplyAutoRegistration();


Mixing with XML:

var context = new XmlApplicationContext( "assembly://Spring.AutoRegistration.Test/
      Spring.AutoRegistration.Test/SpringObjectsSimple.xml");
            context.Configure()
                .IncludeAssembly(x => x.FullName.StartsWith("Spring.AutoRegistration.Test"))
                .Include(x => x.ImplementsITypeName(), Then.Register().UsingSingleton())
                .ApplyAutoRegistration();


Using the NamedAttribute and InjectAttribute:

    // uses the type name
    public class GrayImagePlugin : IImagePlugin
    {
    }
 
    [Named("Resize")]
    public class ResizeImagePlugin : IImagePlugin
    {    
    }
 
    public class PluginExecutor : IPluginExecutor
    {
        [Inject]
        public IImagePlugin GrayImagePlugin { getset; }
 
        [Inject]
        public IImagePlugin Resize { getset; }    
    }   
     

Let me know about issues, bugs and suggestions using the Spring.AutoRegistration.