Exemple #1
0
        public static void ClientV1()
        {
            IChartable chart = ChartFactory.GetChart("histogram");

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

            chart = ChartFactory.GetChart("pie");
            if (chart != null)
            {
                chart.Display();
            }
        }
Exemple #2
0
        // 主函数,我想干啥直接搞接口就行了
        static void Main(string[] args)
        {
            IChartable chart = ChartFactory.GetChart("histogram");

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

            chart = ChartFactory.GetChart("pie");
            if (chart != null)
            {
                chart.Display();
            }
        }
        public static void Main(string[] args)
        {
            IChartable chart = ChartFactory.GetChart("pie");

            chart.Display();
            Console.ReadKey();
        }
Exemple #4
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();
        }
Exemple #5
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();
        }
Exemple #6
0
        public static void ClientV2()
        {
            string type = AppConfigHelper.GetChartType();

            if (string.IsNullOrEmpty(type))
            {
                return;
            }

            IChartable chart = ChartFactory.GetChart(type);

            if (chart != null)
            {
                chart.Display();
            }
        }
        static void Main(string[] args)
        {
            var chartType = GetConfiguration("charttype");

            if (string.IsNullOrEmpty(chartType))
            {
                return;
            }

            IChartable chart = ChartFactory.GetChart(chartType);

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

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            //可以从读取配置文件来获取要创建的图表
            string chartType = ConfigurationManager.AppSettings["chartType"].ToString();

            if (string.IsNullOrEmpty(chartType))
            {
                return;
            }

            //核心逻辑是  在工厂类中实现创建产品的功能
            IChartable chart = ChartFactory.GetChart(chartType);

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