Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Reading students numbers:");
            IMapper   mapper = new Mapper();
            ISplitter split  = new SplittByComma();
            IExporter export = new Exporter();
            IReader   reader = new ReadTextFile();

            ScoreCalculator sc = new ScoreCalculator(reader, mapper, export, split);

            sc.Calculate();

            Console.WriteLine("Finished ...");
            Console.ReadKey();
        }
        static void MainRefactored(string[] args)
        {
            Console.WriteLine("Reading students numbers:");
            var reader   = (IReader)ServiceLocator.Resolve(typeof(IReader));
            var splitter = (ISplitter)ServiceLocator.Resolve(typeof(ISplitter));
            var mapper   = (IMapper)ServiceLocator.Resolve(typeof(IMapper));
            var exporter = (IExporter)ServiceLocator.Resolve(typeof(IExporter));

            ScoreCalculator sc = new ScoreCalculator(reader, mapper, exporter, splitter);

            sc.Calculate();

            Console.WriteLine("Finished ...");
            Console.ReadKey();
        }