Ejemplo n.º 1
0
        public void test()
        {
            IChart chart;

            chart = ChartFactory.GetChart("histo");
            Assert.AreEqual(chart.GetType(), typeof(HistogramChart));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            IChart chart;

            chart = ChartFactory.GetChart("histo");
            chart.Display();
            Console.Read();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 简单工厂模式
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            IChart chart;
            //读取配置文件
            string chartStr = ConfigurationManager.AppSettings["chartType"];

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

            Console.ReadLine();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            /*
             * Product product;
             * product = Factory.GetProduct("A"); //通过工厂类创建产品对象
             * product.MethodSame();
             * product.MethodDiff();
             */
            Chart chart;

            //读取配置文件
            string chartStr = ConfigurationManager.AppSettings["chartType"];

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

            Console.Read();
        }