Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            ConsoleOperation consoleOperation = new ConsoleOperation();

            consoleOperation.Initialize();
            consoleOperation.Show();

            RainOperation rainOperation = new RainOperation(consoleOperation);

            rainOperation.MatrixInitialize();
            rainOperation.Draw();
        }
Ejemplo n.º 2
0
        public RainOperation(ConsoleOperation consoleOperation)
        {
            _consoleOperation = consoleOperation ?? throw new ArgumentException(nameof(consoleOperation));

            _width  = _consoleOperation.ConsoleWidth;
            _height = _consoleOperation.ConsoleHeight;

            _yAxisFirstSection  = new int[_width];
            _yAxisSecondSection = new int[_width];

            _random = new Random();
        }
Ejemplo n.º 3
0
        public bool Run(string[] args)
        {
            _options.Parse(args);

            if (_options.Command == ConsoleCommand.Help)
            {
                return(PrintHelp());
            }

            if (_options.Path == null)
            {
                return(PrintUsage("Error: You must specify a path"));
            }
            if (!_commandTable.ContainsKey(_options.Command))
            {
                return(PrintUsage("Error: No command specified"));
            }

            ConsoleOperation op = _commandTable[_options.Command];

            if (!op.OptionsValid(_options))
            {
                return(PrintError("Error: Invalid options specified for the given command"));
            }

            int successCount = 0;
            int failCount    = 0;

            foreach (var targetNode in new NbtPathEnumerator(_options.Path))
            {
                if (!op.CanProcess(targetNode))
                {
                    Console.WriteLine(targetNode.NodePath + ": ERROR (invalid command)");
                    failCount++;
                }
                if (!op.Process(targetNode, _options))
                {
                    Console.WriteLine(targetNode.NodePath + ": ERROR (apply)");
                    failCount++;
                }

                targetNode.Root.Save();

                Console.WriteLine(targetNode.NodePath + ": OK");
                successCount++;
            }

            Console.WriteLine("Operation complete.  Nodes succeeded: {0}  Nodes failed: {1}", successCount, failCount);

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Process the command line parameters
        /// </summary>
        /// <param name="argv">The command line parameters</param>
        protected void ReadCommandLine(string[] argv)
        {
            int i = 0;

            while (i < argv.Length)
            {
                if (argv[i].StartsWith("/"))
                {
                    // Option:
                    argv[i] = argv[i].ToLower();
                    if (argv[i].Equals("/g"))
                    {
                        // Generate at windows:
                        Op = ConsoleOperation.Generate;
                    }
                    else if (argv[i].Equals("/y"))
                    {
                        // Dont ask for confirmations
                        AskConfirmations = false;
                    }
                    else if (argv[i].Equals("/e"))
                    {
                        ExitAfterGenerate = true;
                    }
                    else if (argv[i].Equals("/?"))
                    {
                        Op = ConsoleOperation.ShowHelp;
                    }
                    else if (argv[i].Equals("/q"))
                    {
                        OutputQuiet = true;
                    }
                    else if (argv[i].Equals("/l1"))
                    {
                        LogLevel = ChmLogLevel.ERROR;
                    }
                    else if (argv[i].Equals("/l2"))
                    {
                        LogLevel = ChmLogLevel.WARNING;
                    }
                    else if (argv[i].Equals("/l3"))
                    {
                        LogLevel = ChmLogLevel.INFO;
                    }
                    else if (argv[i].Equals("/l4"))
                    {
                        LogLevel = ChmLogLevel.DEBUG;
                    }
                    else
                    {
                        Message("Unknown option " + argv[i]);
                        Op = ConsoleOperation.ShowHelp;
                        SetAplicationExitCode(ChmLogLevel.ERROR);
                    }
                }
                else
                {
                    ProjectFile = argv[i];
                }
                i++;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Process the command line parameters
 /// </summary>
 /// <param name="argv">The command line parameters</param>
 public void ReadCommandLine(string[] argv)
 {
     int i = 0;
     while (i < argv.Length)
     {
         if (argv[i].StartsWith("/"))
         {
             // Option:
             argv[i] = argv[i].ToLower();
             if (argv[i].Equals("/g"))
                 // Generate at windows:
                 op = ConsoleOperation.Generate;
             else if (argv[i].Equals("/y"))
                 // Dont ask for confirmations
                 askConfirmations = false;
             else if (argv[i].Equals("/e"))
                 exitAfterGenerate = true;
             else if (argv[i].Equals("/?"))
                 op = ConsoleOperation.ShowHelp;
             else if (argv[i].Equals("/q"))
             {
                 outputQuiet = true;
             }
             else if (argv[i].Equals("/l1"))
             {
                 logLevel = 1;
             }
             else if (argv[1].Equals("/l2"))
             {
                 logLevel = 2;
             }
             else if (argv[1].Equals("/l3"))
             {
                 logLevel = 3;
             }
             else
             {
                 Message("Unknown option " + argv[i]);
                 op = ConsoleOperation.ShowHelp;
             }
         }
         else
             projectFile = argv[i];
         i++;
     }
 }