当前位置: 首页>>代码示例>>C#>>正文


C# CommandLine.Parse方法代码示例

本文整理汇总了C#中CommandLine.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLine.Parse方法的具体用法?C# CommandLine.Parse怎么用?C# CommandLine.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLine的用法示例。


在下文中一共展示了CommandLine.Parse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static int Main( string[] args )
        {
            CommandLine     commandLine = new CommandLine();
            int             returnVal = 0;

            try
            {
                commandLine.Parse( args );

                if( commandLine.Mode == SyncAppMode.RunEngine )
                {
                    RunSyncEngine( commandLine );
                }
                else if( commandLine.Mode == SyncAppMode.CreateConfigTemplate )
                {
                    CreateConfigTemplateFile( commandLine );
                }
            }
            catch( Exception e )
            {
                Console.Error.WriteLine( "Error: {0}", e.ToString() );
                returnVal = -1;
            }

            if( commandLine.PauseOnExit )
            {
                Console.WriteLine();
                Console.WriteLine( "Press any key to exit..." );
                Console.ReadKey( true );
            }

            return returnVal;
        }
开发者ID:dxm007,项目名称:TrackerSync,代码行数:33,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            var commandLine = new CommandLine();
            commandLine.Parse(args);

            var controller = new Controller(commandLine, new Settings());
            controller.Run();

            Console.WriteLine("");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
开发者ID:ichigo333,项目名称:setistat,代码行数:12,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            // Parse Command Line.
            var options = new CommandLine();
            if(!options.Parse(args))
                return;

            // Parse link file.
            var links = new LinkFile();
            if(!links.Load(options.LinkFile))
                return;

            MainLoop(options, links);
        }
开发者ID:jkells,项目名称:tflow,代码行数:14,代码来源:Program.cs

示例4: CustomGame

        public void CustomGame()
        {
            const int game_cnt = 5; // number of games to pass as parameters
            CommandLine line;
            string [] args;
            GameManager.GameLocator [] games;
            GameManager gm = new GameManager ();
            StringBuilder game_list = new StringBuilder ();
            int [] candidates; // Stores the indexes of the games passed as parameters
            int cand_idx = 0;

            games = gm.AvailableGames;
            candidates = new int [game_cnt];

            for (int i = 0; i < games.Length; i++)
            {
                if (games[i].IsGame == false)
                    continue;

                Game game = (Game) Activator.CreateInstance (games[i].TypeOf, true);
                game.Variant = games[i].Variant;

                if (cand_idx > 0)
                    game_list.Append (CommandLine.GAME_SEPARATOR + " ");

                game_list.Append (game.Name);
                candidates [cand_idx++] = i;

                if (cand_idx >= game_cnt)
                    break;
            }

            args = new string [2];
            args [0] = "--customgame";
            args [1] = game_list.ToString ();

            line = new CommandLine (args);
            line.Parse ();

            Assert.AreEqual (cand_idx, line.PlayList.Length);

            cand_idx = 0;
            foreach (int idx in line.PlayList)
                Assert.AreEqual (idx, candidates [cand_idx++]);
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:45,代码来源:CommandLineTest.cs

示例5: Main

        static void Main(string[] args)
        {
            //
            // This is the Bizkit's test area.
            //
            CommandLine cmd = new CommandLine();

            SwitchArg switch_arg = new SwitchArg("testArg", "Test Arg", "Specify if you want to test something");
            cmd.Add(switch_arg);

            ValueArg<int> value_int_arg = new ValueArg<int>("intArg", "Int Arg", "Specify if you want to set int value", true, 5);
            cmd.Add(value_int_arg);

            ValueArg<string> value_string_arg = new ValueArg<string>("stringArg", "String Arg", "Specify if you want to set string value", true, "EMPTY_STRING");
            cmd.Add(value_string_arg);

            Type t = value_int_arg.GetType().GetGenericArguments()[0];

            string[] arguments = new string[] { "dummy_executable_name.exe", "-testArg", "-intArg", "100", "-stringArg", "SomeText" };

            try
            {
                cmd.Parse(arguments);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            //
            // Tests of values stored in arguments
            //
            bool b = switch_arg.Value;
            System.Diagnostics.Debug.Assert(switch_arg.Value == true);

            int i = value_int_arg.Value;
            System.Diagnostics.Debug.Assert(value_int_arg.Value == 100);

            string s = value_string_arg.Value;
            System.Diagnostics.Debug.Assert(value_string_arg.Value == "SomeText");
        }
开发者ID:virious,项目名称:Bizkit,代码行数:41,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            var options = new CommandLine();

            try
            {
                // Read arguments from command line.
                options.Parse(args);

                // Validate all options.
                options.Validate();

                var kernel = new Kernel();

                var s = Stopwatch.StartNew();

                // Run log import
                kernel.Run(options);

                s.Stop();

                ConsoleWriter.WriteInfo("Time taken: {0}", s.Elapsed);

                Environment.Exit(0);
            }
            catch (UsageException exception)
            {
                ConsoleWriter.WriteError(Environment.NewLine + exception.Message);

                options.PrintUsage(Console.Error);

                Environment.Exit(2);
            }
            catch (SystemException exception)
            {
                ConsoleWriter.WriteError(exception.ToString());

                Environment.Exit(1);
            }
        }
开发者ID:peschuster,项目名称:LogImporter,代码行数:40,代码来源:Program.cs

示例7: Execute

        public void Execute(string command)
        {
            var commandLine = new CommandLine(command);
            this.historys.Add(commandLine);
            commandLine.Parse(
                this.Engine.GetCommandMember(z => z.CommandParser),
                this.Engine.GetCommandMember(z => z.CommandParameterParser));

            if (commandLine.CommandBlock == null)
            {
                this.Execute(this.Engine.GetCommandMember(z => z.NoneInput), commandLine);
                this.Execute(this.Engine.GetCommandMember(z => z.Helper), commandLine);
            }
            else
            {
                var mapper = this.GetCommandMapper(commandLine);
                if (mapper != null)
                {
                    this.Execute(mapper, commandLine);
                    return;
                }
                this.Execute(this.Engine.GetCommandMember(z => z.Helper), commandLine);
            }
        }
开发者ID:gitter-badger,项目名称:Jasily.Framework.ConsoleEngine,代码行数:24,代码来源:Session.cs

示例8: Main

        public static void Main(string [] args)
        {
            try {
                Unix.SetProcessName ("gbrainy");
            }
            catch (Exception e)
            {
                Console.WriteLine ("gbrainy.Main. Could not set process name. Error {0}", e);
            }

            DateTime start_time = DateTime.Now;

            InitCoreLibraries ();

            GtkClient app = new GtkClient ();
            CommandLine.Version ();

            CommandLine line = new CommandLine (args);
            line.Parse ();

            if (line.Continue == false)
                return;

            Gtk.Application.Init ();

            app.Initialize ();
            // Set RandomOrder before setting the custom list then it has effect of custom games
            app.Session.GameManager.RandomOrder = line.RandomOrder;
            if (line.PlayList.Length > 0) {
                app.Session.GameManager.PlayList = line.PlayList;
                app.InitialSessionType = GameSession.Types.Custom;
            }
            app.ProcessDefaults ();
            ThemeManager.Load ();

            TimeSpan span = DateTime.Now - start_time;
            Console.WriteLine (Catalog.GetString ("Startup time {0}"), span);
            Gtk.Application.Run ();
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:39,代码来源:gbrainy.cs

示例9: RandomOrder

        public void RandomOrder()
        {
            CommandLine line;
            string [] args;

            args = new string [1];
            args [0] = "--norandom";

            line = new CommandLine (args);
            Assert.AreEqual (true, line.RandomOrder);
            line.Parse ();

            Assert.AreEqual (false, line.RandomOrder);
        }
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:14,代码来源:CommandLineTest.cs

示例10: Application

        public Application(ApplicationInfo info)
        {
            nativeInterface = info.nativeInterface;
            width = info.width;
            height = info.height;
            realWidth = info.realWidth;
            realHeight = info.realHeight;

            sharedApplication = this;

            context = new Context();
            updatables = new UpdatableList(1);
            drawables = new DrawableList(1);

            cmdLine = CreateCommandLine();
            cmdLine.Parse(info.args);
        }
开发者ID:bbqchickenrobot,项目名称:atomic-bomberman-xna,代码行数:17,代码来源:Application.cs


注:本文中的CommandLine.Parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。