public void Main()
        {
            string whatToMake = "car"; // or "van"

            AbstractVehicleFactory factory = null;

            // Create the correct 'factory'...
            if (whatToMake.Equals("car"))
            {
                factory = new CarFactory();
            }
            else
            {
                factory = new VanFactory();
            }

            // Create the vehicle's component parts...
            // These will either be all car parts or all van parts
            IBody    vehicleBody    = factory.CreateBody();
            IChassis vehicleChassis = factory.CreateChassis();
            IWindows vehicleWindows = factory.CreateWindows();

            // Show what we've created...
            Console.WriteLine(vehicleBody.BodyParts);
            Console.WriteLine(vehicleChassis.ChassisParts);
            Console.WriteLine(vehicleWindows.WindowParts);
            Console.Read();
        }
Example #2
0
 public Car(ICarFactory carFactory)
 {
     Body     = carFactory.CreateBody();
     Engine   = carFactory.CreateEngine();
     Interior = carFactory.CreateInterior();
     Wheels   = carFactory.CreateWheels();
     Windows  = carFactory.CreateWindows();
 }
Example #3
0
 public DemoForm(System.Windows.Forms.Control ct)
 {
     InitializeComponent();
     //ct1 = ct;
     ct.Dock = DockStyle.Fill;
     editbaseform = ct as ICSharpCode.SharpDevelop.Gui.IEditBaseForm;
     iclipboard = ct as ICSharpCode.SharpDevelop.Gui.IClipboardHandler;
     windows = ct as IWindows;
     this.Size = ct.Size;
     this.panel1.Controls.Add(ct);
     this.FormClosing += new FormClosingEventHandler(DemoForm_FormClosing);
 }
 public void Stop(IWindows win)
 {
     win.Stop();
 }
 public void Start(IWindows win)
 {
     win.Start();
 }
Example #6
0
 public bool Equals(IWindows other)
 {
     return(Equals(other as SafeComWrapper <object>));
 }
Example #7
0
        private bool DoIsOpen(IWindows windows, string key)
        {
            foreach (Boss boss in windows.All())
            {
                var editor = boss.Get<ITextEditor>();
                if (key == editor.Key)
                    return true;
            }

            return false;
        }
 public bool Equals(IWindows other)
 {
     return(Equals(this, other));
 }
Example #9
0
 // WinForms та DatagridView, яких розуміє тільки Windows
 public static void CreateDataGridViewTable(IWindows windows)
 {
     Console.WriteLine(windows.RunFromWindows());
 }