Ejemplo n.º 1
0
        public void BuildByClassName()
        {
            string        testlibraryPath = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\..\\TestLibrary\\bin\\Debug\\netcoreapp3.1");
            DirectoryInfo di = new DirectoryInfo(testlibraryPath);

            IocUtils.AddSearchPath(di.FullName);

            object a = IocUtils.GetObject("TestLibrary.Person");

            Assert.IsNotNull(a);
            Console.WriteLine("a: " + a);

            dynamic b = IocUtils.GetObject("TestLibrary.Person", "张三");

            Assert.IsNotNull(b);
            Assert.AreEqual("张三", b.Name);
            Console.WriteLine("b: " + b);

            object c = IocUtils.GetObject("TestLibrary.Person", "李四", true);

            Assert.IsNotNull(c);
            Console.WriteLine("c: " + c);

            object d = IocUtils.GetObject("TestLibrary.Person", "王五", (Int16)18, true);

            Assert.IsNotNull(d);
            Console.WriteLine("d: " + d);

            IocUtils.RemoveSearchPath(di.FullName);
        }