Пример #1
0
        static void Main(string[] args)
        {
            // ======== SIMPLE FACTORY ===========
            var smBank = SimpleFactory.getBank("DABank");

            Console.WriteLine(smBank.getBankName());
            //Console.Read();

            // ======== FACTORY METHOD ===========
            IBank fmBank = FactoryMethod.getBank("ACBBank");

            Console.WriteLine(fmBank.getBankName());
            //Console.Read();


            // ABSTRACT FACTORY - show screnario create factory and furniture
            IFurnitureAbstractFactory factory = FurnitureFactory.getFactory(MaterialType.FLASTIC);
            IChair chair = factory.createChair();

            chair.create();
            ITable table = factory.createTable();

            table.create();

            // ABSTRACT FACTORY - hide screnario create factory and furniture
            // can not use var c = ...
            IChair c = FurnitureFactory.createFurniture(MaterialType.WOOD, FurnitureType.CHAIR);

            c.create();
            Console.Read();
        }
        /// <summary>
        /// Simulates the client code only knowing it gets a Factory.
        /// Probably some service/handler that gets injected with the IFurnitureFactory
        /// but does not know what implementation types
        /// </summary>
        private static void DescribeChair(IFurnitureFactory factory)
        {
            IChair chair = factory.CreateChair();

            chair.SitOn();
            chair.HasLegs();
        }
        static void Main(string[] args)
        {
            // Modern things

            IFurnitureFactory furnitureFactory = new ModernFurnitureFactory();

            IChair chair = furnitureFactory.CreateChair();
            ITable table = furnitureFactory.CreateCoffeeTable();

            chair.HasLegs();
            chair.SitOn();

            table.Shape();
            table.SitNextTo();

            // Viktorian things

            furnitureFactory = new ViktorianFurnitureFactory();

            chair = furnitureFactory.CreateChair();
            table = furnitureFactory.CreateCoffeeTable();

            chair.HasLegs();
            chair.SitOn();

            table.Shape();
            table.SitNextTo();
        }
Пример #4
0
 public Workplace(IChair chair, DeskType deskType, int deskWidth, int deskLength, int deskHeight)
 {
     Chair      = chair;
     DeskType   = deskType;
     DeskWidth  = deskWidth;
     DeskLength = deskLength;
     DeskHeight = deskHeight;
 }
Пример #5
0
        public void ShoudWorkForHomeFurnitureCreation()
        {
            IFurnitureFactory officeFurnitureFactory = new HomeFurnitureFactory();
            IChair            chair = officeFurnitureFactory.CreateChair();
            ITable            table = officeFurnitureFactory.CreateTable();

            chair.GetType().Name.Should().Be("SofaChair");
            table.GetType().Name.Should().Be("DyningTable");
        }
Пример #6
0
        public void ShoudWorkForOfficeFurnitureCreation()
        {
            IFurnitureFactory officeFurnitureFactory = new OfficeFurnitureFactory();
            IChair            chair = officeFurnitureFactory.CreateChair();
            ITable            table = officeFurnitureFactory.CreateTable();

            chair.GetType().Name.Should().Be("ComputerChair");
            table.GetType().Name.Should().Be("ComputerTable");
        }
Пример #7
0
            public void DisplayProducts()
            {
                IChair chair = factory.CreateChair();

                Console.WriteLine($"{chair.Name}, has legs: {chair.HasLegs}");

                ISofa sofa = factory.CreateSofa();

                Console.WriteLine($"{sofa.Name}, can sit on: {sofa.CanSitOn}");
            }
Пример #8
0
 private WorkplaceBuilder(WorkplaceBuilder other)
 {
     this.optionals    = other.optionals.Clone();
     this.deskType     = other.deskType;
     this.width        = other.width;
     this.height       = other.height;
     this.length       = other.length;
     this.chair        = other.chair;
     this.employeeName = other.employeeName;
 }
Пример #9
0
 public Task<int> InsertAsync(IChair entity)
 {
     try
     {
         return Repository.InsertAsync(entity);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #10
0
 public virtual Task<int> DeleteAsync(IChair entity)
 {
     try
     {
         return Repository.DeleteAsync<Chair>(Mapper.Map<Chair>(entity));
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
Пример #11
0
 public virtual Task<int> UpdateAsync(IChair entity)
 {
     try
     {
         return Repository.UpdateAsync<Chair>(Mapper.Map<Chair>(entity));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #12
0
 public Task<int> DeleteAsync(IChair entity)
 {
     try
     {
         return Repository.DeleteAsync(entity);
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
Пример #13
0
        static void Main(string[] args)
        {
            FuritureAbstractFactory factory = FurnitureFactory.GetFactory(MaterialType.Plastic);

            IChair chair = factory.CreateChair();

            chair.Create(); // create a plastic chair

            ITable table = factory.CreateTable();

            table.Create(); // create a plastic table
        }
Пример #14
0
        static void Main(string[] args)
        {
            FurnitureAbstractFactory factory = FurnitureFactory.getFactory(MaterialType.FLASTIC);

            IChair chair = factory.createChair();

            chair.create(); // Create plastic chair

            ITable table = factory.createTable();

            table.create(); // Create plastic table
        }
Пример #15
0
        void ShowRoomProject(IRoomFactory roomFactory)
        {
            Console.WriteLine();
            Console.WriteLine("Budujemy pokoj w stylu " + roomFactory.GetType().Name);
            Console.WriteLine("Pokoj będzię się składał z:");
            IChair chair = roomFactory.CreateChair();

            Console.WriteLine(chair.Show());
            ISofa sofa = roomFactory.CreateSofa();

            Console.WriteLine(sofa.Show());
            Console.WriteLine();
        }
Пример #16
0
 public UnitOfWork(DbContext context)
 {
     this.context = context;
     category     = new CategoryRepo(context);
     chair        = new ChairRepo(context);
     consumer     = new ConsumerRepo(context);
     customer     = new CustomerRepo(context);
     theater      = new HomeTheaterRepo(context);
     product      = new ProductRepo(context);
     subCategory  = new SubCategoryRepo(context);
     table        = new TableRepo(context);
     tv           = new TVRepo(context);
     user         = new UserRepo(context);
 }
Пример #17
0
 public void ShowInfomationWithChair(IChair chair)
 {
     Console.WriteLine(GetTableInfo() + " with " + chair.GetChairInfo());
 }
Пример #18
0
 public INeedsAnDesk SetChair(IChair chair)
 {
     this.chair = chair;
     return(new WorkplaceBuilder(this));
 }
Пример #19
0
 public static Set CreateSetWithChairAndCoffeTable(IChair chair, ICoffeTable coffeTable)
 {
     return(new Set(chair, coffeTable));
 }
Пример #20
0
 public Set(IChair chair, ICoffeTable coffeTable, ISofa sofa) : this(chair, coffeTable)
 {
     Sofa = sofa;
 }
Пример #21
0
 private Set(IChair chair, ICoffeTable coffeTable)
 {
     Chair      = chair;
     CoffeTable = coffeTable;
 }
Пример #22
0
 public ShopClient(IShop s, CommonEnums.ChairTypes cTypes, CommonEnums.SofaTypes sTypes)
 {
     chair = s.GetChair(cTypes);
     sofa  = s.GetSofa(sTypes);
 }
Пример #23
0
        public string Print(IChair collaborator)
        {
            var result = collaborator.Style();

            return($"The result of the VictorianSofa colaborating with the ({result})");
        }
Пример #24
0
 public void CreateFurniture(IFactory factory)
 {
     a = factory.CreateChair();
     b = factory.CreateTable();
 }
Пример #25
0
 public FurnitureSeller()
 {
     factory = new T();
     sofa    = factory.CreateSofa();
     chair   = factory.CreateChair();
 }
Пример #26
0
 private void ShowChairInfo(IChair chair)
 {
     Console.WriteLine($"{chair.GetType().Name} has legs: {chair.HasLegs()}");
     chair.SitOn();
 }
Пример #27
0
 public Client(IFactory factory)
 {
     _abstractTable = factory.CreateTable();
     _abstractChair = factory.CreateChair();
 }
Пример #28
0
        public string AnotherUsefulFunctionCoffeeTable(IChair collaboratorChair)
        {
            var result = collaboratorChair.SitOn();

            return($"The result of Modern coffee Table collaborating with {result}");
        }
Пример #29
0
 public KitchenFacade(ITable table, IChair chair)
 {
     _table = table;
     _chair = chair;
 }
 public FurnitureOrder(FurnitureFactory factory)
 {
     _chair = factory.GetChairs();
     _desk  = factory.GetTables();
 }
Пример #31
0
 public Client(IFactory factory)
 {
     _productChair = factory.CreateProductChair();
     _productTable = factory.CreateProductTable();
 }
Пример #32
0
 public void CreateFurniture()
 {
     this.ch = this.f.CreateChair();
     this.t  = this.f.CreateTable();
 }
Пример #33
0
        public string Print(IChair collaborator)
        {
            var result = collaborator.Style();

            return($"The result of the Modern sofa is colaborating with the ({result})");
        }
Пример #34
0
 public void Fit(IChair chair)
 {
     Console.WriteLine($"{chair.GetType().Name} perfectly fits to the {GetType().Name}");
 }