コード例 #1
0
        public void TestForkWorks()
        {
            Type checkChildIfaceType = typeof(Com.Microsoft.Tang.Examples.CheckChildIface);
            Type checkChildImplType  = typeof(Com.Microsoft.Tang.Examples.CheckChildImpl);

            ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(new string[] { file });

            cb.Bind(checkChildIfaceType, checkChildImplType);

            IInjector       i  = TangFactory.GetTang().NewInjector(cb.Build());
            IInjector       i1 = i.ForkInjector();
            CheckChildIface c1 = (CheckChildIface)i1.GetInstance(checkChildIfaceType);
            IInjector       i2 = i.ForkInjector();
            CheckChildIface c2 = (CheckChildIface)i2.GetInstance(checkChildIfaceType);

            Assert.AreNotEqual(c1, c2);
        }