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(); } }
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(); }
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); }
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); }
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; }
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(); }
private void FillColorButton_Click(object sender, EventArgs e) { tool = new FillTool(); _factory = null; }
private void EraserButton_Click(object sender, EventArgs e) { tool = new EraserTool(); _factory = null; }
private void toolMoveButton_Click(object sender, EventArgs e) { tool = new FigureMoveTool(); _factory = null; }
private void circleToolStripMenuItem_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new CircleFactory(); }
private void EllipseButton_Click_1(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new EllipseFactory(); }
private void equilateralTriangleToolStripMenuItem_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new TriangleEquilateralFactory(); //равносторонний треугольник по одной стороне }
private void rightTriangleToolStripMenuItem_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new TriangleRightFactory(); //прямоугольный треугольник по гипотенузе }
private void isoscelesTriangleToolStripMenuItem_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new TriangleIsoscelesFactory(); //равнобедренный треугольник по одной из граней }
private void LineButton_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new LineFactory(); }
private void Pencil_Click(object sender, EventArgs e) { tool = new FigureDrawTool(); _factory = new PencilFactory(); }
public Client(AFactory factory) { _core = factory.CreateCore(); _shell = factory.CreateShell(); }
private void AngleButton_Click(object sender, EventArgs e) { tool = new ResizeTool(); _factory = null; }
static void Main(string[] args) { AFactory.RunFactories(); }