Faux Banque is a experimental place for learning how to use Akka Dot Net with Domain Driven Design (DDD). Along with experimenting with DDD Aggregate design it also provides an example of how to implement an Akka Extension to provide depenency injection using a WindsorContainer.

My IOC example is based on a translation of a Java implementation using the Spring Framework. The Java code Spring Implementation is an excellent source of information if you are attempting to write your own version from scratch. If you want to use my implementation with a different container refer to the ApplicationConfig class and create your own implementation.

 public class ApplicationConfig : IApplicationContext
 {
    private IWindsorContainer container;
    private Akka.Configuration.Config config;

    public ApplicationConfig(IWindsorContainer container)
    {
        this.container = container;
    }

    public ApplicationConfig(IWindsorContainer container, 
                             Akka.Configuration.Config config)
    {
        this.container = container;
        this.config = config;
    }
    public ActorSystem actorSystem(string SystemName)
    {

        var system = ActorSystem.Create(SystemName,config);
        system.RegisterExtension((IExtensionId)DIExtension.DIExtensionProvider);

        DIExtension.DIExtensionProvider.Get(system).Initialize(this);
        return system;
    }                                                                                                

    public Type GetType(string ActorName)
    {
        return 
            container.
            Kernel.
            GetAssignableHandlers(typeof(object)).
            Where(handler => handler.
                             ComponentModel.
                             Name.
                             Equals(ActorName,
                                    StringComparison.InvariantCultureIgnoreCase)).
            Select(handler => handler.ComponentModel.Implementation).
            FirstOrDefault();
    }

    public Func<ActorBase> CreateActor(string ActorName)
    {
        return () => (ActorBase)container.Resolve(GetType(ActorName));
    }



}