Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hsmm Error Sources Generation Application started");
            Console.WriteLine(
                "Please, specify Pseudo Random Generator mode as a number from the list:\r\n" +
                " 0 - Standart; \r\n" +
                " 1 - RC4; \r\n" +
                " 2 - Security");
            PseudoRandomGeneratorType prngMode = PromptParseUtils.ParsePseudoRandomGeneratorType(Console.ReadLine());

            Task.Factory.StartNew(() =>
            {
                bool ifExit = false;
                while (!ifExit)
                {
                    Console.WriteLine(
                        "Please, specify generation parameters");
                    string jsonModel = null;

                    while (jsonModel == null)
                    {
                        Console.WriteLine(
                            "Specify path to model file:");
                        string pathToFile = Console.ReadLine();
                        jsonModel         = ParseModelFile(pathToFile);
                    }

                    Console.WriteLine(
                        "Specify desired sequence length:");
                    int sequenceLength = Convert.ToInt32(Console.ReadLine());

                    string outputPath = null;

                    while (outputPath == null)
                    {
                        Console.WriteLine("Specify output file path:");
                        outputPath = ParseOutputPath(Console.ReadLine());
                    }

                    Console.WriteLine("Starting generation");
                    GenerationManager manager = new GenerationManager(prngMode);
                    GenerationResult result   = manager.Generate(jsonModel, sequenceLength);
                    if (result.HasErrors())
                    {
                        Console.WriteLine("Generation failed due to the following errors:" + String.Join(", ", result.Errors.ToArray()));
                    }
                    else
                    {
                        WriteOutputToFile(outputPath, result.Value);
                        Console.WriteLine("Generation has been successfully completed. See result in " + outputPath);
                    }

                    Console.WriteLine("Do you want to continue? (y/n)");
                    ifExit = !PromptParseUtils.ParseBoolean(Console.ReadLine());
                }
                Console.WriteLine("Press Ctrl+C to exit...");
            });

            Console.CancelKeyPress += new ConsoleCancelEventHandler(OnExit);
            Closing.WaitOne();
        }