예제 #1
0
        public Container()
        {
            beans = new Dictionary<string, object>();
            Console.WriteLine("初始化Container...");
            //把generator/manager加进beans
            IGenerator pdf = new PdfGenerator();
            beans.Add("pdf", pdf);

            GeneratorManager manager = new GeneratorManager(pdf);
            beans.Add("manager", manager);
            Console.WriteLine("结束初始化Container...");
        }
예제 #2
0
        public Container()
        {
            beans = new Dictionary <string, object>();
            Console.WriteLine("初始化Container...");
            //把generator/manager加进beans
            IGenerator pdf = new PdfGenerator();

            beans.Add("pdf", pdf);

            GeneratorManager manager = new GeneratorManager(pdf);

            beans.Add("manager", manager);
            Console.WriteLine("结束初始化Container...");
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("direct invoke...");


            new Container();
            GeneratorManager manager = (GeneratorManager)Container.GetBean("manager");

            manager.DoSomething();
            //Manager与接口有耦合关系
            //generator = manager.generator;


            //generator.Generate();
            Console.WriteLine("----------------------------------------");

            Console.ReadKey();
        }