Example #1
0
 public Client(AbstractFactory factory)
 {
     water = factory.CreateWater();
     bottle = factory.CreateBottle();
     label = factory.CreateLabel();
     cover = factory.CreateCover();
 }
Example #2
0
 public Client(AbstractFactory factory)
 {
     // јбстрагирование процесса инстанцировани¤.
     water = factory.CreateWater();
     bottle = factory.CreateBottle();
     cover = factory.CreateCover();
 }
Example #3
0
 static Example Create(AbstractFactory factory)
 {
     Example example = new Example();
     example.product1 = factory.CreateProduct1(10);
     example.product2 = factory.CreateProduct2(20f);
     example.product3 = factory.CreateProduct3("thirty");
     return example;
 }
Example #4
0
 public Client(AbstractFactory factory)
 {
     ProductA productA = factory.CreateProductA();
     ProductB productB = factory.CreateProductB();
 }
Example #5
0
 public Client(AbstractFactory factory)
 {
     water = factory.CreateWater();
     bottle = factory.CreateBottle();
 }
 public Player(AbstractFactory factory)
 {
     _abstractHorse = factory.CreateUnitHorse();
     _abstractHorseman = factory.CreateUnitHorseman();
 }
Example #7
0
 public Client(AbstractFactory factory)
 {
     // јбстрагирование процесса инстанцировани¤.
     water  = factory.CreateWater();
     bottle = factory.CreateBottle();
 }
Example #8
0
 public Client(AbstractFactory factory)
 {
     water  = factory.CreateWater();
     bottle = factory.CreateBottle();
 }
Example #9
0
 public Client(AbstractFactory factory)
 {
     _abstractAssets = factory.BundleAssets();
     _abstractBuild  = factory.BuildForPlatform();
 }
Example #10
0
 public Client(AbstractFactory factory)
 {
     _abstractProductB = factory.CreateProductB();
     _abstractProductA = factory.CreateProductA();
 }
Example #11
0
 public GameManager(AbstractFactory abstractFactory)
 {
     this.abstractFactory = abstractFactory;
 }
Example #12
0
 public void ChangeFactory(AbstractFactory factory)
 {
     this.factory = factory;
     water        = factory.CreateWater();
     bottle       = factory.CreateBottle();
 }
Example #13
0
 public void SetFactory(AbstractFactory factory)
 {
     this.factory = factory;
 }
Example #14
0
 public Application(AbstractFactory factory)
 {
     _factory = factory;
 }
Example #15
0
 // Constructor
 public Client(AbstractFactory factory)
 {
     _abstractProductB = factory.CreateProductB();
     _abstractProductA = factory.CreateProductA();
 }
Example #16
0
 public Client(AbstractFactory factory)
 {
     haircut  = factory.DoHaircut();
     coloring = factory.DyeHair();
 }
Example #17
0
 public Client(AbstractFactory abstractFactory)
 {
     abstractProductA = abstractFactory.CreateProductA();
     abstractProductB = abstractFactory.CreateProductB();
 }
Example #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("//------------------- Simple Factory Pattern ----------------------//");
            //Declare simple factory.
            SF.AnimalFactory animalFactory = new SF.AnimalFactory();

            //Use factory to create objects.
            SF.Dog sfDog = animalFactory.createDog();
            SF.Cat sfCat = animalFactory.createCat();

            Console.WriteLine("//------------------- Factory Method Pattern ----------------------//");
            //Define factories with overridden factory methods.
            FM.CatFactory catFactory = new FM.CatFactory();
            FM.DogFactory dogFactory = new FM.DogFactory();

            //Use factories to define objects based on the same type.
            FM.IAnimal fmDog = dogFactory.Create();
            FM.IAnimal fmCat = catFactory.Create();

            fmDog.makeSound();
            fmCat.makeSound();

            Console.WriteLine("//------------------- Abstract Factory Pattern ----------------------//");

            //Use the hidden factory instantiation logic to two factories.
            AF.AbstractFactory Factory1 = AF.FactoryFactory.Create("animal");
            AF.AbstractFactory Factory2 = AF.FactoryFactory.Create("clothing");

            //Use the factories to create the needed objects.
            AF.IAnimal afDog = Factory1.getAnimal("dog");
            AF.IAnimal afCat = Factory1.getAnimal("cat");

            AF.IClothing afHat   = Factory2.getClothing("hat");
            AF.IClothing afPants = Factory2.getClothing("pants");

            //Output data to make sure everything went OK.
            afDog.makeSound();
            afCat.makeSound();

            afHat.printDescription();
            afPants.printDescription();

            Console.WriteLine("//------------------- Adapter Design Pattern ----------------------//");

            AP.IAnimal  apDog         = new AP.Dog();
            AP.IAnimal  apCat         = new AP.Cat();
            AP.IVehicle jaguar        = new AP.Car();
            AP.IAnimal  adaptedJaguar = new AP.AnimalVehicleAdapter(jaguar);

            List <AP.IAnimal> animals = new List <AP.IAnimal>();

            animals.Add(apDog);
            animals.Add(apCat);
            animals.Add(adaptedJaguar);

            foreach (AP.IAnimal animal in animals)
            {
                animal.makeSound();
            }


            Console.WriteLine("//------------------- Command Design Pattern ----------------------//");
            //Define objects.
            IVehicle AudiA6    = new Car();
            IVehicle Cessna172 = new Plane();

            //Specific commands that hide the actual implementation.
            ICommand carGearUp   = new CarGearUp(AudiA6);
            ICommand planeGearUp = new PlaneGearUp(Cessna172);
            ICommand turnAllOff  = new TurnAllVehiclesOff(new List <IVehicle>()
            {
                AudiA6, Cessna172
            });

            //A schedular that holds a couple commands ready to be executed at a later time.
            List <ICommand> scheduler = new List <ICommand>();

            scheduler.Add(carGearUp);
            scheduler.Add(planeGearUp);
            scheduler.Add(turnAllOff);

            //We don't need to know anything about the objects or the commands to execute them
            //This level of encapsulation is what the command design pattern is all about.
            foreach (ICommand cmnd in scheduler)
            {
                cmnd.Execute();
            }
            Console.ReadLine();
        }
Example #19
0
 public Client(AbstractFactory factory)
 {
     this._cover  = factory.CreateCover();
     this._bottle = factory.CreateBottle();
     this._water  = factory.CreateWater();
 }