ex ) 신발가게에서 신발을 주문하면 공장에서 만드는 시나리오
public class Shoes
{
public string Name{get; set;}
public int Size{get; set;}
}
interface IShoesFactory
{
public Shoes MakeShoes();
}
public class NShoes : IShoesFactory
{
public Shoes MakeShoes()
{
return new Shoes()
{
Name = "df",
Size = 250
}
}
}
public class AShoes : IShoesFactory
{
public Shoes MakeShoes()
{
return new Shoes()
{
Name = "adf",
Size = 260
}
}
}
public class ShoesStore
{
IShoesFactory shoesFactory = null;
public Shoes OrderShoes(string shoesName)
{
if("NShoes".Equals(shoesName))
{
shoesFactory = new NShoes();
}
...
return shoesFactory.MakeShoes();
}
}
static void Main(string[] args)
{
ShoesStore shoesStore = new ShoesStore();
Shoes myNesShoes = shoesStore.OrderShoes("NShoes");
}
public class ShoesStore
{
public Shoes OrderShoes(IShoesFactory shoesFactory)
{
return shoesFactory.MakeShoes();
}
}
static void Main(string[] args)
{
ShoesStore shoesStore = new ShoesStore();
Shoes myNesShoes = shoesStore.OrderShoes(new NShoes());
}
[WPF] Dependency Property Metadata (0) | 2022.04.19 |
---|---|
[WPF] Databinding (0) | 2022.04.18 |
[WPF] Pack uri (0) | 2022.04.15 |
c# (WPF) Data Binding 에 대해서 (0) | 2021.05.31 |
nInject 사용하는 간단한 방법 (0) | 2021.05.29 |
댓글 영역