예제 #1
0
        private static IContainer InitContainer()
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(StubFactory.GetCurrentProvider()).SingleInstance();
            builder.RegisterInstance(StubFactory.GetDbConfig()).SingleInstance();
            builder.Register(c =>
            {
                var dbConfig = c.Resolve <IDbConfig>();
                return(new NHibernateSessionSource(() => DataManagerFactory.CreateSessionFactory(dbConfig)));
            }).As <IConnectionSource <ISession> >().SingleInstance();

            builder.RegisterType <QueueRepository>().As <IQueueRepository>().As <IClearable>().SingleInstance();
            builder.RegisterType <DbQueueService>().As <IQueueService>().SingleInstance();

            return(builder.Build());
        }