コード例 #1
0
ファイル: Program.cs プロジェクト: AndrewGomzyakov/di
        static void Main(string[] args)
        {
            var          arguments = ParseArguments(args);
            var          bgColor   = arguments["--bgColor"];
            var          textColor = arguments["--textColor"];
            IPointsMaker pointsMaker;

            if (arguments["--form"] == "sqrt")
            {
                pointsMaker = new SquarePointsMaker();
            }
            else if (arguments["--form"] == "trgl")
            {
                pointsMaker = new TrianglePointsMaker();
            }
            else
            {
                pointsMaker = new ArchimedesSpiralPointsMaker();
            }

            ITextReader textReader;

            if (arguments["--fileFormat"] == "doc" ||
                arguments["--fileFormat"] == "docx")
            {
                textReader = new DocTextReader();
            }
            else
            {
                textReader = new TxtTextReader();
            }

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance(textReader).As <ITextReader>();
            containerBuilder.RegisterType <SimpleWordParser>().As <IWordParser>();
            containerBuilder.RegisterType <SimpleWordChanger>().As <IWordChanger>();
            containerBuilder.RegisterType <TextParser>().As <ITextParcer>();
            containerBuilder.RegisterInstance(new CloudLayouter(CloudCenter, 1, pointsMaker))
            .As <ICloudLayouter>()
            .SingleInstance();
            containerBuilder.RegisterInstance(new Visualizer(PictureSize, bgColor, textColor))
            .As <Visualizer>()
            .SingleInstance();
            containerBuilder.RegisterType <ConsoleApplication>();
            var container = containerBuilder.Build();

            var app    = container.Resolve <ConsoleApplication>();
            var input  = arguments["--input"];
            var output = arguments["--output"];

            app.Run(input, output);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var          arguments = ParseArguments(args);
            var          bgColor   = arguments["--bgColor"];
            var          textColor = arguments["--textColor"];
            IPointsMaker pointsMaker;

            if (arguments["--form"] == "sqrt")
            {
                pointsMaker = new SquarePointsMaker();
            }
            else if (arguments["--form"] == "trgl")
            {
                pointsMaker = new TrianglePointsMaker();
            }
            else
            {
                pointsMaker = new ArchimedesSpiralPointsMaker();
            }

            ITextReader textReader;

            if (arguments["--fileFormat"] == "doc" ||
                arguments["--fileFormat"] == "docx")
            {
                textReader = new DocTextReader();
            }
            else
            {
                textReader = new TxtTextReader();
            }

            var input  = arguments["--input"];
            var output = arguments["--output"];
            var app    = new ConsoleApplication();

            app.Run(input, output, new TextParser(textReader, new SimpleWordChanger(),
                                                  Result.Of(() => new SimpleWordParser(), "Dictionary not found.")),
                    new CloudLayouter(CloudCenter, 1, pointsMaker),
                    new Visualizer(PictureSize, bgColor, textColor))
            .OnFail(Console.WriteLine);
        }