當前位置: 首頁>>代碼示例>>C#>>正文


C# System.CommandLine類代碼示例

本文整理匯總了C#中System.CommandLine的典型用法代碼示例。如果您正苦於以下問題:C# CommandLine類的具體用法?C# CommandLine怎麽用?C# CommandLine使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommandLine類屬於System命名空間,在下文中一共展示了CommandLine類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CsvViewer

 public CsvViewer(CommandLine.CommandLine cmd, FileIO fio, Ui ui, Formatieren format)
 {
     _cmd = cmd;
     _fio = fio;
     _ui = ui;
     _format = format;
 }
開發者ID:ralfw,項目名稱:dnp2013,代碼行數:7,代碼來源:CsvViewer.cs

示例2: RunApplication

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

            using (var @lock = CreateLock(string.IsNullOrEmpty(commandLine.LockName) ? @"F17BFCF1-0832-4575-9C7D-F30D8C359159" : commandLine.LockName, commandLine.AddGlobalPrefix))
            {
                Console.WriteLine("Acquiring lock");

                @lock.Lock();
                Console.WriteLine("Acquired lock");
                try
                {
                    Console.WriteLine("Holding lock for {0} seconds", commandLine.HoldTime);
                    Thread.Sleep(1000*commandLine.HoldTime);
                }
                finally
                {
                    Console.WriteLine("Released lock");
                    @lock.Unlock();
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
        }
開發者ID:kevinpig,項目名稱:MyRepository,代碼行數:26,代碼來源:ExclusiveLockTestApplication.cs

示例3: Main

        static void Main(string[] args)
        {
            System.Windows.Forms.Application.EnableVisualStyles();

            if (LoadConfiguration(args))
            {
                Configuration.Environment = ExecutionEnvironment.WindowsApplication;
                ICommandLine commandLine = new CommandLine(args);

                string titleArgument = commandLine.GetArgument("title");
                string projectPath = commandLine.GetArgument("project");
                string viewName = commandLine.GetArgument("view");
                string recordId = commandLine.GetArgument("record");

                try
                {
                    Epi.Windows.Enter.EnterMainForm mainForm = new Epi.Windows.Enter.EnterMainForm();

                    if (!mainForm.IsDisposed)
                    {
                        mainForm.Show();
                        if (mainForm.WindowState == FormWindowState.Minimized)
                        {
                            mainForm.WindowState = FormWindowState.Normal;
                        }

                        mainForm.Activate();

                        mainForm.Text = string.IsNullOrEmpty(titleArgument) ? mainForm.Text : titleArgument;

                        if (!string.IsNullOrEmpty(projectPath))
                        {
                            Project project = new Project(projectPath);

                            mainForm.CurrentProject = project;

                            if (string.IsNullOrEmpty(recordId))
                            {
                                mainForm.FireOpenViewEvent(project.Views[viewName]);
                            }
                            else
                            {
                                mainForm.FireOpenViewEvent(project.Views[viewName], recordId);
                            }
                        }
                        //--2225
                        Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                       //--
                        System.Windows.Forms.Application.Run(mainForm);

                    }

                    mainForm = null;
                }
               catch (Exception baseException)
                {
                    MsgBox.ShowError(string.Format("Error: \n {0}", baseException.ToString()));
                }
            }
        }
開發者ID:NALSS,項目名稱:epiinfo-82474,代碼行數:60,代碼來源:EntryPoint.cs

示例4: Initialise

 protected override void Initialise(CommandLine cl)
 {
     if (cl.args.Count == 1)
         volumeId = cl.args[0].Trim();
     else
         throw new SyntaxException("The snapshot command requires one parameter");
 }
開發者ID:siganakis,項目名稱:s3-tool-encrypted,代碼行數:7,代碼來源:Snapshot.cs

示例5: Main

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            var commandLine = new CommandLine(args);

            if (commandLine.RunAsService)
            {
                ServiceBase[] servicesToRun = new ServiceBase[] {new ShredHostService()};
                ServiceBase.Run(servicesToRun);
            }
            else if (!String.IsNullOrEmpty(commandLine.PreviousExeConfigurationFilename))
            {
                var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups();
                foreach (var group in groups)
                    SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename);

                ShredSettingsMigrator.MigrateAll(commandLine.PreviousExeConfigurationFilename);
            }
            else		
            {
                Thread.CurrentThread.Name = "Main thread";
                if (!ManifestVerification.Valid)
                    Console.WriteLine("The manifest detected an invalid installation.");
                ShredHostService.InternalStart();
                Console.WriteLine("Press <Enter> to terminate the ShredHost.");
                Console.WriteLine();
                Console.ReadLine();
                ShredHostService.InternalStop();
            }

        }
開發者ID:nhannd,項目名稱:Xian,代碼行數:33,代碼來源:Program.cs

示例6: Execute

        public void Execute(CommandLine commandLine, CommandExecutionContext context)
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;

            Console.WriteLine("==================================================");
            Console.WriteLine(" Welcome to {0} {1}", ApplicationInfo.Title, ApplicationInfo.Version.ToString(2));
            Console.WriteLine(" " + ApplicationInfo.Description);
            Console.WriteLine(" " + ApplicationInfo.CopyrightHolder);
            Console.WriteLine("==================================================");

            Console.ResetColor();

            Console.WriteLine();
            Console.WriteLine("Available commands are:");

            foreach (var cmd in CommandFactory.All)
            {
                Console.Write("-" + cmd.Name);
                Console.Write("\t");

                if (!String.IsNullOrEmpty(cmd.ShortName))
                {
                    Console.Write("[" + cmd.ShortName + "] ");
                }

                Console.Write(cmd.Description);

                if (!String.IsNullOrEmpty(cmd.Usage))
                {
                    Console.Write(" Usage: " + cmd.Usage);
                }

                Console.WriteLine();
            }
        }
開發者ID:mouhong,項目名稱:XHost,代碼行數:35,代碼來源:HelpCommand.cs

示例7: Execute

        public void Execute(CommandLine commandLine, CommandExecutionContext context)
        {
            if (commandLine.Parameters.Count != 2)
            {
                ConsoleUtil.ErrorLine("Invalid request. Please check syntax: " + Usage);
                return;
            }

            var host = commandLine.Parameters[1];
            var ip = commandLine.Parameters[0];

            if (context.Hosts.Contains(host))
            {
                if (commandLine.Options.Count > 0 && commandLine.Options[0].Name == "override")
                {
                    context.Hosts.Set(ip, host);
                    context.Hosts.Save();

                    Console.WriteLine("1 entry updated: " + commandLine.Parameters[0] + " " + commandLine.Parameters[1]);
                }
                else
                {
                    ConsoleUtil.ErrorLine(host + " already exists. Use -override to override the existing entry.");
                }
            }
            else
            {
                context.Hosts.Set(commandLine.Parameters[0], commandLine.Parameters[1]);
                context.Hosts.Save();

                Console.WriteLine("1 entry added: " + commandLine.Parameters[0] + " " + commandLine.Parameters[1]);
            }
        }
開發者ID:mouhong,項目名稱:XHost,代碼行數:33,代碼來源:AddEntryCommand.cs

示例8: CheckOptions

 public override void CheckOptions(CommandLine cmd)
 {
     // Confidence estimator
     double confidence = Allcea.DEFAULT_CONFIDENCE;
     double sizeRel = Allcea.DEFAULT_RELATIVE_SIZE;
     double sizeAbs = Allcea.DEFAULT_ABSOLUTE_SIZE;
     if (cmd.HasOption('c')) {
         confidence = AbstractCommand.CheckConfidence(cmd.GetOptionValue('c'));
     }
     if (cmd.HasOption('s')) {
         string[] sizeStrings = cmd.GetOptionValues('s');
         if (sizeStrings.Length != 2) {
             throw new ArgumentException("Must provide two target effect sizes: relative and absolute.");
         }
         sizeRel = AbstractCommand.CheckRelativeSize(sizeStrings[0]);
         sizeAbs = AbstractCommand.CheckAbsoluteSize(sizeStrings[1]);
     }
     this._confEstimator = new NormalConfidenceEstimator(confidence, sizeRel, sizeAbs);
     // Double format
     if (cmd.HasOption('d')) {
         this._decimalDigits = AbstractCommand.CheckDigits(cmd.GetOptionValue('d'));
     }
     // Files
     this._inputPath = AbstractCommand.CheckInputFile(cmd.GetOptionValue('i'));
     if (cmd.HasOption('j')) {
         this._judgedPath = AbstractCommand.CheckJudgedFile(cmd.GetOptionValue('j'));
     }
     this._estimatedPath = AbstractCommand.CheckEstimatedFile(cmd.GetOptionValue('e'));
 }
開發者ID:wxbjs,項目名稱:Allcea,代碼行數:29,代碼來源:EvaluateCommand.cs

示例9: GetCommand

        /// <summary>
        /// 獲取用戶命令。
        /// </summary>
        /// <param name="args">命令行參數。</param>
        /// <param name="verb">命令代號。</param>
        /// <returns></returns>
        public static CommandLine GetCommand(string[] args, string verb)
        {
            CommandLine command = null;

            if (args != null && args.Length > 0)
            {
                if (verb.IndexOf('-') != 0)
                    verb = "-" + verb;

                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i] == verb)
                    {
                        command = new CommandLine(verb, String.Empty);
                        if (args[i + 1].IndexOf(("-")) != 0)
                        {
                            command.Parameter = args[i + 1];
                        }
                        break;
                    }
                }
            }

            return command;
        }
開發者ID:karl-barkmann,項目名稱:LeenLeen,代碼行數:31,代碼來源:CommandLineHelper.cs

示例10: Main

        public static void Main(string[] args)
        {
            CommandLine commandLine = new CommandLine(args);

            switch(commandLine.Action)
            {
                case "new":
                    // Create a new employee
                    Console.WriteLine("'Creating' a new Employee.");
                    break;
                case "update":
                    // Update an existing employee's data
                    Console.WriteLine("'Updating' a new Employee.");
                    break;
                case "delete":
                    // Remove an existing employee's file
                    Console.WriteLine("'Removing' a new Employee.");
                    break;
                default:
                    Console.WriteLine(
                        "Employee.exe new|update|delete " +
                        "<id> [firstname] [lastname]");
                    break;
            }
        }
開發者ID:troubleminds,項目名稱:TIP,代碼行數:25,代碼來源:Listing05.45.DefiningANestedClass.cs

示例11: Run

        public void Run(string[] args)
        {
            CommandLine commandLine = new CommandLine();
            commandLine.AddOption("Verbose", false, "-verbose");

            commandLine.Parse(args);

            if ((bool)commandLine.GetOption("-h"))
            {
                commandLine.Help("Katahdin Interpreter");
                return;
            }

            Runtime runtime = new Runtime(true, false, false, false,
                (bool)commandLine.GetOption("-verbose"));

            //new ConsoleParseTrace(runtime);

            runtime.SetUp(commandLine.Args);

            if (!((bool)commandLine.GetOption("-nostd")))
                runtime.ImportStandard();

            foreach (string file in commandLine.Files)
                runtime.Import(file);
        }
開發者ID:schuster-rainer,項目名稱:katahdin,代碼行數:26,代碼來源:EntryPoint.cs

示例12: Main

    	/// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            var commandLine = new CommandLine(args);

            if (commandLine.RunAsService)
            {
                var ServicesToRun = new ServiceBase[] { new ShredHostService() };
                ServiceBase.Run(ServicesToRun);
            }
            else if (!String.IsNullOrEmpty(commandLine.PreviousExeConfigurationFilename))
            {
                var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups();
                groups.Add(new SettingsGroupDescriptor(typeof (ShredSettingsMigrator).Assembly.GetType("ClearCanvas.Server.ShredHost.ShredHostServiceSettings")));
                foreach (var group in groups)
                    SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename);

                ShredSettingsMigrator.MigrateAll(commandLine.PreviousExeConfigurationFilename);
            }
            else
            {
                ShredHostService.InternalStart();
                Console.WriteLine("Press <Enter> to terminate the ShredHost.");
                Console.WriteLine();
                Console.ReadLine();
                ShredHostService.InternalStop();
            }
        }
開發者ID:emmandeb,項目名稱:ClearCanvas-1,代碼行數:30,代碼來源:Program.cs

示例13: CreateInstance

 public static void CreateInstance(string commandName, CommandLine commandLine)
 {
     commandLine.command = CreateInstance(commandName);
     if (commandLine.command == null)
         throw new SyntaxException(string.Format("Unknown command: {0}", commandName));
     else
         commandLine.command.Initialise(commandLine);
 }
開發者ID:OlegBoulanov,項目名稱:s3e,代碼行數:8,代碼來源:Command.cs

示例14: RunApplication

        public void RunApplication(string[] args)
        {
            var commandLine = new CommandLine(args);

        	var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups();
            foreach (var group in groups)
                SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename);
        }
開發者ID:emmandeb,項目名稱:ClearCanvas-1,代碼行數:8,代碼來源:MigrateLocalSharedSettingsApplication.cs

示例15: Initialise

        protected override void Initialise(CommandLine cl)
        {
            if (cl.args.Count > 0)
                command = Command.CreateInstance(cl.args[0]);

            if (command == null)
                command = this;
        }
開發者ID:OlegBoulanov,項目名稱:s3e,代碼行數:8,代碼來源:Help.cs


注:本文中的System.CommandLine類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。