Ejemplo n.º 1
0
        public void SetContainerThrowsIfContainerIsAlreadySet()
        {
            SetContainer(null);

            DryIocServiceHostFactory.SetContainer(_container.Object);
            Assert.Throws <InvalidOperationException>(() => DryIocServiceHostFactory.SetContainer(_container.Object));
        }
Ejemplo n.º 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            // Create the container as usual.
            var container = new Container(rules =>
                                          rules.WithDefaultReuse(Reuse.InCurrentScope), scopeContext: null);

            container.Register(typeof(ISampleService), typeof(SampleService), Reuse.Transient);
            container.Register(typeof(IFoo), typeof(Foo));
            container.Register(typeof(IBar), typeof(Bar));
            container.Register(typeof(ISingleton), typeof(Singleton), Reuse.Singleton);
            container.Register(typeof(ITransient), typeof(Transient), Reuse.Transient);
            container.Register(typeof(IAsyncClass), typeof(AsyncClass));
            DryIocServiceHostFactory.SetContainer(container);
        }
Ejemplo n.º 3
0
 public void SetContainerThrowsIfContainerIsNull()
 {
     SetContainer(null);
     Assert.Throws <ArgumentNullException>("container", () => DryIocServiceHostFactory.SetContainer(null));
 }