static void Main(string[] args) { IFactory factoryWin = new WinFactory(); IFactory factoryLin = new LinuxFactory(); IFactory factoryMac = new MacFactory(); List <IFactory> list = new List <IFactory>(new IFactory[] { factoryWin, factoryLin, factoryMac }); foreach (IFactory factory in list) { var b = factory.createButton(); var r = factory.createRadioButton(); var c = factory.createCheckBox(); Console.WriteLine("I'm {0} factory with objects:", factory.GetType().Name); Console.WriteLine("\t {0} {1} {2}", b.GetType().Name, r.GetType().Name, c.GetType().Name); } }
static void Main(string[] args) { var factory1 = new LinuxFactory(); var client = new Client(factory1); }