Пример #1
0
        public void FactoryTest()
        {
            {
                // 开始做西红柿炒蛋
                Creator factory            = new ShreddedPorkWithPotatoesFactory();
                var     tomatoScrambleEggs = factory.CreateFoodFactory();
                tomatoScrambleEggs.Print();
                factory = new TomatoScrambledEggsFactory();

                //开始做土豆肉丝
                var shreddedPorkWithPotatoes = factory.CreateFoodFactory();
                shreddedPorkWithPotatoes.Print();
            }

            {
                var factory   = new StoreFactory();
                var commodity = factory.GetCommodity(1);
                commodity.SendCommodity("1", "2");
                commodity = factory.GetCommodity(2);
                commodity.SendCommodity("1", "2");
            }
            {
                var a = new AFactory().CreateProduct();
                a.Show();
                var b = new BFactory().CreateProduct();
                b.Show();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            AFactory     af = AFactory.CreateBLLFactory();
            IUserInfoBLL ib = af.CreateUserInfoBLLInstance();
            UserInfo     u  = ib.Where().FirstOrDefault();

            Console.Write("用户ID:{0},用户名:{1}", u.UserId, u.UserName);
            Console.ReadKey();
        }
Пример #3
0
        public void CreateTest()
        {
            Factory factory = new AFactory();

            factory.Create();
            Assert.Equal("ProductA", factory.Product.GetType().Name);
            Assert.Equal("AirConditionA", factory.AirCondition.GetType().Name);
            Assert.Equal("CameraA", factory.Camera.GetType().Name);
        }
Пример #4
0
 void ProcessNext(Object data)
 {
     try
     {
         IRequestProcessorFactory factory   = new AFactory();
         RequestProcessor         processor = new RequestProcessor(factory);
         processor.ProcessNext();
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
 }
        static void AbstractFactory()
        {
            IFruitFactory fac      = new AFactory();
            Fruit         a_Apple  = fac.CreateApple("a工厂");
            Fruit         a_Orange = fac.CreateOrange("a工厂");

            a_Apple.PrintfName();
            a_Orange.PrintfName();

            IFruitFactory b_fac    = new BFactory();
            Fruit         b_Apple  = b_fac.CreateApple("b工厂");
            Fruit         b_Orange = b_fac.CreateOrange("b工厂");

            b_Apple.PrintfName();
            b_Orange.PrintfName();
        }
        public IAFactory CreateAFactory()
        {
            IAFactory factory = null;

            try
            {
                factory = new AFactory();
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(factory);
        }
Пример #7
0
 private void Rotate180_Click(object sender, EventArgs e)
 {
     _factory = null;
     _currentFigure._angle = -180 * Math.PI / 180;
     sBitmap.Clear();
     sBitmap.DrawExceptIndexFigures(_currentFigure);
     sBitmap.Copy();
     sBitmap.FillExceptIndexFigures(_currentFigure);
     sBitmap.CopyFromFill();
     pictureBox1.Image = sBitmap._tmpBitmap;
     sBitmap.Update();
     _currentFigure.Rotate();
     sBitmap.Copy();
     sBitmap.vDrawFigure(_currentFigure);
     sBitmap.Copy();
     sBitmap.FillFigure(_currentFigure);
     sBitmap.CopyFromFill();
     sBitmap.Update();
     pictureBox1.Image = sBitmap._bitmap;
 }
Пример #8
0
        static void Main(string[] args)
        {
            AFactory myfactory = FabrikaGetir("Anadol");
            AAraba   mycar     = myfactory.ArabaYap();
            AParca   parca     = myfactory.ParcaYap();

            mycar.Calıstır();
            mycar.Durdur();
            Console.WriteLine(parca.GetName());



            myfactory = FabrikaGetir("Toros");
            mycar     = myfactory.ArabaYap();
            parca     = myfactory.ParcaYap();
            mycar.Calıstır();
            mycar.Durdur();
            Console.WriteLine(parca.GetName());

            Console.ReadLine();
        }
Пример #9
0
 private void FillColorButton_Click(object sender, EventArgs e)
 {
     tool     = new FillTool();
     _factory = null;
 }
Пример #10
0
 private void EraserButton_Click(object sender, EventArgs e)
 {
     tool     = new EraserTool();
     _factory = null;
 }
Пример #11
0
 private void toolMoveButton_Click(object sender, EventArgs e)
 {
     tool     = new FigureMoveTool();
     _factory = null;
 }
Пример #12
0
 private void circleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new CircleFactory();
 }
Пример #13
0
 private void EllipseButton_Click_1(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new EllipseFactory();
 }
Пример #14
0
 private void equilateralTriangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new TriangleEquilateralFactory(); //равносторонний треугольник по одной стороне
 }
Пример #15
0
 private void rightTriangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new TriangleRightFactory(); //прямоугольный треугольник по гипотенузе
 }
Пример #16
0
 private void isoscelesTriangleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new TriangleIsoscelesFactory(); //равнобедренный треугольник по одной из граней
 }
Пример #17
0
 private void LineButton_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new LineFactory();
 }
Пример #18
0
 private void Pencil_Click(object sender, EventArgs e)
 {
     tool     = new FigureDrawTool();
     _factory = new PencilFactory();
 }
Пример #19
0
 public Client(AFactory factory)
 {
     _core  = factory.CreateCore();
     _shell = factory.CreateShell();
 }
Пример #20
0
 private void AngleButton_Click(object sender, EventArgs e)
 {
     tool     = new ResizeTool();
     _factory = null;
 }
Пример #21
0
 static void Main(string[] args)
 {
     AFactory.RunFactories();
 }