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(); }
static void Main(string[] args) { string carName = args[0]; IAuto car = GetCar(carName); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { 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(); }
static void Main(string[] args) { string carName = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
private static void Main(string[] args) { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAutoMobile(); car.Start(); car.Stop(); Console.ReadKey(); }
public void main(string[] args) { string carName = args[0]; SimpleFactory factory = new SimpleFactory(); IAuto car = factory.CreateInstance("BMW335Xi"); car.TurnOn(); car.TurnOff(); }
static void executeSimpleFactory() { IAutoFactory autoFactory = new BMWFactory(); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); Console.ReadKey(); }
static void Main(string[] args) { var autoFactory = new AutoFactory(); IAuto car = autoFactory.CreateInstance("Audi"); car.On(); car.Off(); Console.ReadKey(); }
static void Main(string[] args) { var autoRep = new AutoRepository(); IAuto auto1 = autoRep.Find(1); auto1.Start(); auto1.Stop(); Console.WriteLine("Hello World!"); Console.ReadKey(); }
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() { //IAutoFactory autoFactory = new BMWFactory(); 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) { 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{ IAuto auto = AutoFactory.CreateAutoInstance("Toyota"); auto.TurnOn(); auto.TurnOff(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { string input = ReadInput(); var factory = VehicleFactory.Build(input); IAuto car = factory; car.TurnOn(); car.TurnOff(); }
static void Main() { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAutomobile(); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
static void Main(string[] args) { IAutoFactory autoFactory = LoadFactory(); IAuto car = autoFactory.CreateAuto(); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
public void CreateInstance_GivenASpecificCarName_ReturnsTheAppropriateIAutoInstance(string carName, Type expectedCarType) { //arrange AutoFactory autoFactory = new AutoFactory(); //act IAuto actualCar = autoFactory.CreateInstance(carName); //assert actualCar.Should().BeOfType(expectedCarType); }
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 CreateAutomobile_ReturnsTheConfiguredIAutoInstance() { //arrange IAutoFactory autoFactory = LoadFactory.GetInstance(); Type expectedAutomobileType = typeof(MiniCooper); //act IAuto actualAutomobile = autoFactory.CreateAutomobile(); //assert actualAutomobile.Should().BeOfType(expectedAutomobileType); }
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(); }
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(); }
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(); }
public IAuto CreateInstance(string typeName) { IAuto instance = null; Type type = getCarType(typeName); if (type == null) { instance = new UndefinedAuto(); } else { instance = Activator.CreateInstance(type) as IAuto; } return(instance); }
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(); }
public decimal Reparatur(IAuto auto) { if (BieteReparaturAn(auto)) { if (auto is IOldtimer) { return(1529.45m); } else if (auto is INeuwagen) { return(989.95m); } } return(0); }
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(); }