// The simple factory method has a big flaw where the factory knows about the // concrete class being created, where as the abstract and factory method only know of the interfaces // The bmw and audi concrete creation could all be different, as so can use the factory method to // centralize the creation so the client only knows about the factory and not the complex creation static void Main(string[] args) { #region Simple Factory var carName = args[0]; SimpleAutoFactory factory = new SimpleAutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); #endregion #region Factory Method IAutoFactory autoFactory = LoadFactory(); IAuto autoCar = autoFactory.CreateAuto(); car.TurnOn(); car.TurnOff(); #endregion }
static void Main(string[] args) { string carName = Console.ReadLine(); IAuto car = GetCar(carName); car.TurnOn(); car.TurnOff(); }
public void main(string[] args) { string carName = args[0]; IAuto car = GetCar(carName); car.TurnOn(); car.TurnOff(); }
private static void RunSimpleFactory(string carName) { AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); }
public void TestVersion02(string carName) { AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); }
public SimpleFactoryPattern(string carName) { AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOff(); car.TurnOn(); }
private void btnFactory_Click(object sender, EventArgs e) { //IAutoFactory autoFactory = new BMWFactory(); IAutoFactory autoFactory = LoadAutoFactory(txtCarType.Text); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); }
public FactoryMethodPattern(string carName) { IAutoFactory factory = LoadFactories(); IAuto car = factory.CreateAutomobile(); car.TurnOff(); car.TurnOn(); }
static void Main() { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); }
public static void SwitchCaseDemo() { string carCommand = Console.ReadLine(); IAuto car = SwichCaseFactory.GetCar(carCommand); car.TurnOn(); car.TurnOff(); }
public void main(string[] args) { string carName = args[0]; SimpleFactory factory = new SimpleFactory(); IAuto car = factory.CreateInstance("BMW335Xi"); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { string carName = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
static void executeSimpleFactory() { IAutoFactory autoFactory = new BMWFactory(); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
public static void Main(string[] args) { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); }
public static void InitializeReflectionDemo() { string carCommand = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carCommand); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { string input = ReadInput(); var factory = VehicleFactory.Build(input); IAuto car = factory; car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { try{ IAuto auto = AutoFactory.CreateAutoInstance("Toyota"); auto.TurnOn(); auto.TurnOff(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { string carName = args[0]; AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAuto(); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
static void Main(string[] args) { Console.Write("Enter car name: "); var input = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(input); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { try{ IAutoFactory autoFactory = LoadFactory(); IAuto auto = autoFactory.CreateAuto(); auto.TurnOn(); auto.TurnOff(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { Console.WriteLine("Enter name of car"); string carName = Console.ReadLine(); // string carName = args[0]; IAuto car = GetCar(carName); car.TurnOn(); car.TurnOff(); }
public void Test_CreateCar() { // Factory method pattern IAutoFactory factory = CreateFactory(); IAuto auto = factory.CreateAuto(); // Simple factory approach //CarFactory manager = new CarFactory(); //NOTE: factory type has to be known by the caller in simple factory approach //IAuto auto = manager.CreateInstance("audi"); auto.TurnOn(); auto.TurnOff(); }
public static void Main(string[] args) { var careName = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto auto = factory.CreateInstance(careName); auto.TurnOn(); auto.TurnOff(); Console.ReadLine(); }
static void Main(string[] args) { string carName = args[0]; //IAuto car = GetCar(carName); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Enter name of car"); string carName = Console.ReadLine(); //string carName = args[0]; AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
static void Main(string[] args) { string carName = args[0]; //Caller knows about the concrete factory type here //Meaning the caller knows which factory type to be called Autofactory factory = new Autofactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main() { IAutoFactory autoFactory = LoadFactory(); //Caller just delegates the pobject creation to a specific factory //which takes the a configuration based approach to decide which factory to return and //which in turn decides which concrete class to return //Here the factory is known but the creation is centralised to specific factory //Also more customized objects can be created. IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main(string[] args) { string name = string.Empty; if (args.Length > 0) { name = args[0]; } AutoFactory factory = new AutoFactory(); IAuto car = factory.GetAuto(name); //IAuto car = GetCar(name); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main() { while (true) { Console.WriteLine("hit enter to create a car..."); Console.ReadLine(); IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAutomobile(); var myCar = new BMW328i(); car.TurnOn(); car.TurnOff(); } }