static void Main(string[] args) { Calculator calc = new Calculator(); calc.operations = new List<IOperation>(new IOperation[] { new OpPlus(), new OpMinus(), new OpMult(), new OpDiv()}); String s; Console.WriteLine("Enter Command:"); while (true) { s = Console.ReadLine(); Console.WriteLine(calc.Calculate(s)); } }
static void Main(string[] args) { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(Program).Assembly)); CompositionContainer container = new CompositionContainer(catalog); Calculator calc = new Calculator(); container.ComposeParts(calc); // calc.operations = new List<IOperation>(new IOperation[] { new OpPlus(), new OpMinus(), new OpMult(), new OpDiv()}); String s; Console.WriteLine("Enter Command:"); while (true) { s = Console.ReadLine(); Console.WriteLine(calc.Calculate(s)); } }