Esempio n. 1
0
        public void TestLegacyConstructor()
        {
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder();

            IList <string> constructorArg = new List <string>();

            constructorArg.Add(ReflectionUtilities.GetAssemblyQualifiedName(typeof(int)));
            constructorArg.Add(ReflectionUtilities.GetAssemblyQualifiedName(typeof(string)));
            cb.RegisterLegacyConstructor(ReflectionUtilities.GetAssemblyQualifiedName(typeof(LegacyConstructor)), constructorArg);
            //cb.Bind(typeof(LegacyConstructor), typeof(LegacyConstructor));
            cb.BindImplementation(GenericType <LegacyConstructor> .Class, GenericType <LegacyConstructor> .Class);

            IInjector i = tang.NewInjector(cb.Build());

            i.BindVolatileInstance(GenericType <int> .Class, 42);
            i.BindVolatileInstance(GenericType <string> .Class, "The meaning of life is ");
            LegacyConstructor l = i.GetInstance <LegacyConstructor>();

            Assert.AreEqual(42, l.X);
            Assert.AreEqual("The meaning of life is ", l.Y);
        }