Exemple #1
0
        public void TestSingletonByName()
        {
            var container = new CryoContainer();

            container.RegisterSingleton <MyClazz>("MyClazz");

            Assert.IsNull(container.WeakResolveByName <MyClazz>("MyClazz"));
            var clazz = container.ResolveByName <MyClazz>("MyClazz");

            Assert.IsNotNull(clazz);

            var clazz2 = container.WeakResolveByName <MyClazz>("MyClazz");

            Assert.IsNotNull(clazz2);
            Assert.AreSame(clazz, clazz2);

            try
            {
                container.WeakResolve <MyClazz>();
                Assert.Fail("Exception expected");

                //ascxasxasxasx
            }
            catch (ContainerException)
            {
                return;
            }
        }
Exemple #2
0
 public T Resolve(params object[] parameters)
 {
     return(_container.WeakResolveByName <T>(_name, parameters));
 }