Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string carName = args[0];

            IAuto car = GetCar(carName);

            car.TurnOn();
            car.TurnOff();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            string      carName = Console.ReadLine();
            AutoFactory factory = new AutoFactory();
            IAuto       car     = factory.CreateInstance(carName);

            car.TurnOn();
            car.TurnOff();
            Console.ReadLine();
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 8
0
        static void executeSimpleFactory()
        {
            IAutoFactory autoFactory = new BMWFactory();

            IAuto car = autoFactory.CreateAutomobile();

            car.TurnOn();
            car.TurnOff();
            Console.ReadKey();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            var   autoFactory = new AutoFactory();
            IAuto car         = autoFactory.CreateInstance("Audi");

            car.On();
            car.Off();

            Console.ReadKey();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            var   autoRep = new AutoRepository();
            IAuto auto1   = autoRep.Find(1);

            auto1.Start();
            auto1.Stop();

            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            string carName = args[0];

            AutoFactory factory = new AutoFactory();

            IAuto car = factory.CreateInstance(carName);

            car.TurnOn();
            car.TurnOff();
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
 static void Main(string[] args)
 {
     try{
         IAuto auto = AutoFactory.CreateAutoInstance("Toyota");
         auto.TurnOn();
         auto.TurnOff();
     }
     catch (Exception ex) {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            string input = ReadInput();

            var factory = VehicleFactory.Build(input);

            IAuto car = factory;

            car.TurnOn();
            car.TurnOff();
        }
Exemplo n.º 17
0
        static void Main()
        {
            IAutoFactory autoFactory = LoadFactory();

            IAuto car = autoFactory.CreateAutomobile();

            car.TurnOn();
            car.TurnOff();

            Console.ReadLine();
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            IAutoFactory autoFactory = LoadFactory();

            IAuto car = autoFactory.CreateAuto();

            car.TurnOn();
            car.TurnOff();

            Console.ReadLine();
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 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();
        }
Exemplo n.º 22
0
        public void CreateAutomobile_ReturnsTheConfiguredIAutoInstance()
        {
            //arrange
            IAutoFactory autoFactory            = LoadFactory.GetInstance();
            Type         expectedAutomobileType = typeof(MiniCooper);

            //act
            IAuto actualAutomobile = autoFactory.CreateAutomobile();

            //assert
            actualAutomobile.Should().BeOfType(expectedAutomobileType);
        }
Exemplo n.º 23
0
        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();
        }
Exemplo n.º 24
0
        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();
        }
Exemplo n.º 25
0
        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();
        }
Exemplo n.º 26
0
        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();
        }
Exemplo n.º 28
0
        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);
 }
Exemplo n.º 30
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();
        }