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(); }
public Workplace(IChair chair, DeskType deskType, int deskWidth, int deskLength, int deskHeight) { Chair = chair; DeskType = deskType; DeskWidth = deskWidth; DeskLength = deskLength; DeskHeight = deskHeight; }
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"); }
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"); }
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}"); }
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; }
public Task<int> InsertAsync(IChair entity) { try { return Repository.InsertAsync(entity); } catch (Exception e) { throw e; } }
public virtual Task<int> DeleteAsync(IChair entity) { try { return Repository.DeleteAsync<Chair>(Mapper.Map<Chair>(entity)); } catch (Exception e) { throw new Exception(e.ToString()); } }
public virtual Task<int> UpdateAsync(IChair entity) { try { return Repository.UpdateAsync<Chair>(Mapper.Map<Chair>(entity)); } catch (Exception e) { throw e; } }
public Task<int> DeleteAsync(IChair entity) { try { return Repository.DeleteAsync(entity); } catch (Exception e) { throw new Exception(e.ToString()); } }
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 }
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 }
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(); }
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); }
public void ShowInfomationWithChair(IChair chair) { Console.WriteLine(GetTableInfo() + " with " + chair.GetChairInfo()); }
public INeedsAnDesk SetChair(IChair chair) { this.chair = chair; return(new WorkplaceBuilder(this)); }
public static Set CreateSetWithChairAndCoffeTable(IChair chair, ICoffeTable coffeTable) { return(new Set(chair, coffeTable)); }
public Set(IChair chair, ICoffeTable coffeTable, ISofa sofa) : this(chair, coffeTable) { Sofa = sofa; }
private Set(IChair chair, ICoffeTable coffeTable) { Chair = chair; CoffeTable = coffeTable; }
public ShopClient(IShop s, CommonEnums.ChairTypes cTypes, CommonEnums.SofaTypes sTypes) { chair = s.GetChair(cTypes); sofa = s.GetSofa(sTypes); }
public string Print(IChair collaborator) { var result = collaborator.Style(); return($"The result of the VictorianSofa colaborating with the ({result})"); }
public void CreateFurniture(IFactory factory) { a = factory.CreateChair(); b = factory.CreateTable(); }
public FurnitureSeller() { factory = new T(); sofa = factory.CreateSofa(); chair = factory.CreateChair(); }
private void ShowChairInfo(IChair chair) { Console.WriteLine($"{chair.GetType().Name} has legs: {chair.HasLegs()}"); chair.SitOn(); }
public Client(IFactory factory) { _abstractTable = factory.CreateTable(); _abstractChair = factory.CreateChair(); }
public string AnotherUsefulFunctionCoffeeTable(IChair collaboratorChair) { var result = collaboratorChair.SitOn(); return($"The result of Modern coffee Table collaborating with {result}"); }
public KitchenFacade(ITable table, IChair chair) { _table = table; _chair = chair; }
public FurnitureOrder(FurnitureFactory factory) { _chair = factory.GetChairs(); _desk = factory.GetTables(); }
public Client(IFactory factory) { _productChair = factory.CreateProductChair(); _productTable = factory.CreateProductTable(); }
public void CreateFurniture() { this.ch = this.f.CreateChair(); this.t = this.f.CreateTable(); }
public string Print(IChair collaborator) { var result = collaborator.Style(); return($"The result of the Modern sofa is colaborating with the ({result})"); }
public void Fit(IChair chair) { Console.WriteLine($"{chair.GetType().Name} perfectly fits to the {GetType().Name}"); }