Esempio n. 1
0
    public static IDependencyInjectionContainer Compose()
    {
        // Create new container
        var container = new Grace.DependencyInjection.DependencyInjectionContainer();

        // Install MVC sitemap provider
        container.Configure(new MvcSiteMapProviderModule());

        // Install Controllers
        container.Configure(new MvcModule());

        // Add your DI configuration here

        return(new GraceDependencyInjectionContainer(container.RootScope));
    }
Esempio n. 2
0
        public ContainerTests()
        {
            LightInjectContainer
            .Register <ITransient1, Transient1>()
            .Register <ITransient2, Transient2>()
            .Register <ITransient3, Transient3>()
            .Register <ISingleton1, Singleton1>(new PerContainerLifetime())
            .Register <ISingleton2, Singleton2>(new PerContainerLifetime())
            .Register <ISingleton3, Singleton3>(new PerContainerLifetime());


            DryIocContainer.Register <ITransient1, Transient1>();
            DryIocContainer.Register <ITransient2, Transient2>();
            DryIocContainer.Register <ITransient3, Transient3>();
            DryIocContainer.Register <ISingleton1, Singleton1>();
            DryIocContainer.Register <ISingleton2, Singleton2>();
            DryIocContainer.Register <ISingleton3, Singleton3>();


            GraceContainer.Configure(ioc =>
            {
                ioc.Export <Transient1>().As <ITransient1>();
                ioc.Export <Transient2>().As <ITransient2>();
                ioc.Export <Transient3>().As <ITransient3>();
                ioc.Export <Singleton1>().As <ISingleton1>().Lifestyle.Singleton();
                ioc.Export <Singleton2>().As <ISingleton2>().Lifestyle.Singleton();
                ioc.Export <Singleton3>().As <ISingleton3>().Lifestyle.Singleton();
            });
        }
 public void Add(Type value, Type type, object withKey)
 {
     _DependencyInjectionContainer.Configure(c => c.Export(value).AsKeyed(type, withKey));
 }
        public TransientBenchmarks()
        {
            container
            .Register <ITransient1, Transient1>()
            .Register <ITransient2, Transient2>()
            .Register <ITransient3, Transient3>();

            dryIocContainer.Register <ITransient1, Transient1>();
            dryIocContainer.Register <ITransient2, Transient2>();
            dryIocContainer.Register <ITransient3, Transient3>();

            graceContainer.Configure(ioc =>
            {
                ioc.Export <Transient1>().As <ITransient1>();
                ioc.Export <Transient2>().As <ITransient2>();
                ioc.Export <Transient3>().As <ITransient3>();
            });
        }