static void Main(string[] args)
        {
            Chart chart;
            //读取配置文件
            string chartStr = ConfigurationManager.AppSettings["chartType"];

            chart = ChartFactory.GetChart(chartStr); //通过静态工厂方法创建产品
            chart.Display();

            Console.Read();
        }
Esempio n. 2
0
        public static void Main()
        {
            IChartable chart = ChartFactory.GetChart("histogram");

            if (chart != null)
            {
                chart.Display();
            }

            chart = ChartFactory.GetChart("pie");
            if (chart != null)
            {
                chart.Display();
            }
            Console.ReadKey();
        }
Esempio n. 3
0
        /*
         * 简单工厂
         * 一个工厂 依赖抽象产品
         * 抽象产品
         * 具体产品 实现抽象产品
         */
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IChartable chart = ChartFactory.GetChart("histogram");

            if (chart != null)
            {
                chart.Display();
            }

            Console.WriteLine();

            chart = ChartFactory.GetChart("pie");
            if (chart != null)
            {
                chart.Display();
            }

            Console.ReadKey();
        }