• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# OptionSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OptionSet的典型用法代码示例。如果您正苦于以下问题:C# OptionSet类的具体用法?C# OptionSet怎么用?C# OptionSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OptionSet类属于命名空间,在下文中一共展示了OptionSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ParsedArguments

        public ParsedArguments(string[] args) {
            var p = new OptionSet {
                {"sum", "If set Sum will be calculated", _ => _SumValues = true},
                {"max", "If set show Max value", _ => _MaxValue = true},
                {"min", "If set show Min value", _ => _MinValue = true},
                {"dir=", "Output directory", dir => _OutputDirectory = GetValidPath(dir)}, {
                    "count=", "Count of items to be generated. This value is mandatory.", count => {
                        if (!_CountIsSet && int.TryParse(count, out _Count) && _Count > 0) {
                            _CountIsSet = true;
                        }
                    }
                }
            };

            p.Parse(args);

            if (!ArgsAreValid) {
                Trace.WriteLine("Parameter args does not contain valid value for count.");

                using (var stringWriter = new StringWriter()) {
                    p.WriteOptionDescriptions(stringWriter);
                    _ErrorMessage = stringWriter.ToString();
                }
            }
        }
开发者ID:matafonoff,项目名称:Brokeree.Test,代码行数:25,代码来源:ParsedArguments.cs


示例2: Run

		public override void Run (IEnumerable<string> args)
		{
			string rootPath = null;

			var options = new OptionSet () {
				{ "r=|root=", "Specify which documentation root to use. Default is $libdir/monodoc", v => rootPath = v },
			};

			var extra = Parse (options, args, "index", 
			                   "[OPTIONS]+ ACTION",
			                   "Create Monodoc indexes depending on ACTION. Possible values are \"tree\" or \"search\" for, respectively, mdoc tree and lucene search");
			if (extra == null)
				return;

			var root = string.IsNullOrEmpty (rootPath) ? RootTree.LoadTree () : RootTree.LoadTree (rootPath);

			foreach (var action in extra) {
				switch (action) {
				case "tree":
					RootTree.MakeIndex (root);
					break;
				case "search":
					RootTree.MakeSearchIndex (root);
					break;
				}
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:27,代码来源:index.cs


示例3: Parse

        public InstanceConfiguration Parse(IList<string> args)
        {
            var cfg = new InstanceConfiguration
                {
                    AppName = string.Empty,
                    Help = false,
                    Verbose = false,
                    ExtraParams = new List<string>()
                };

            var p = new OptionSet
                {
                    {"app=", v => cfg.AppName = v},
                    {"i|install", v => cfg.Install = v != null},
                    {"v|verbose", v => cfg.Verbose = v != null},
                    {"h|?|help", v => cfg.Help = v != null},
                };
            cfg.OptionSet = p;

            if (args == null || !args.Any())
            {
                cfg.Help = true;
                return cfg;
            }

            cfg.ExtraParams = p.Parse(args);
            cfg.AppName = cfg.AppName.Trim('"', '\'');
            return cfg;
        }
开发者ID:repne,项目名称:deployd-micro,代码行数:29,代码来源:ArgumentParser.cs


示例4: Run

        public override void Run(ApplicationContext appContext, IEnumerable<string> args)
        {
            string release = null;
            string env = null;
            var dryRun = false;
            var resume = false;
            var noCache = appContext.UserConfig.Cache.Disabled;
            var noBeeps = false;

            var p = new OptionSet
            {
                { "r=|release=", "Select which release to use, instead of the default.", v => release = v },
                { "e=|env=|environment=", "Select which environment to use, instead of the default.", v => env = v },
                { "n|dry-run", "Don't actually run actions, just print what would be done and exit.", v => dryRun = v != null },
                { "s|resume", "Resume a failed deploy, if possible.", v => resume = v != null },
                { "C|no-cache", "Disable cache.", v => noCache = v != null },
                { "B|no-beeps", "Disable buzzer.", v => noBeeps = v != null }
            };

            var extra = Parse(p, args,
                CommandConstants.Deploy,
                "[OPTIONS]+");
            if (extra == null)
                return;

            var runContext = RunContext.Create(appContext, CommandConstants.Deploy, release, env, dryRun);
            RunCore(DeployContext.Create(runContext, resume, noCache, noBeeps));
        }
开发者ID:aiedail92,项目名称:DBBranchManager,代码行数:28,代码来源:DbbmDeployCommand.cs


示例5: Options

        public Options(params string[] args)
        {
            Port = DefaultPort;
            AssemblyPaths = new Collection<string>();

            options = new OptionSet
                          {
                              {
                                  "p|port=",
                                  "the {PORT} the server should listen on (default=" + DefaultPort + ").",
                                  (int v) => Port = v
                                  },
                              {
                                  "a|assembly=",
                                  "an assembly to search for step definition methods.",
                                  v => AssemblyPaths.Add(v)
                                  },
                              {
                                  "h|?|help",
                                  "show this message and exit.",
                                  v => ShowHelp = v != null
                                  }
                          };
            options.Parse(args);
        }
开发者ID:dwhelan,项目名称:Cuke4Nuke,代码行数:25,代码来源:Options.cs


示例6: Main

    public static int Main(string[] args)
    {
        TextWriter writer = Console.Out;
        string method_name = null;
        string formatter = null;
        bool show_help = false;

        var os = new OptionSet () {
            { "formatter=", "Source code formatter. Valid values are: 'csharp-coregraphics'", v => formatter = v },
            { "out=", "Source code output", v => writer = new StreamWriter (v) },
            { "h|?|help", "Displays the help", v => show_help = true },
        };

        var svg = os.Parse (args);
        string path = (svg.Count > 1) ? String.Concat (svg) : svg [0];

        if (show_help)
            Usage (os, null);

        var parser = new SvgPathParser ();

        switch (formatter) {
        case "csharp-coregraphics":
        case "cs-cg":
            parser.Formatter = new CSharpCoreGraphicsFormatter (writer);
            break;
        default:
            Usage (os, "error: unkown {0} code formatter", formatter);
            break;
        }

        parser.Parse (path, method_name);
        return 0;
    }
开发者ID:joehanna,项目名称:svgpath2code,代码行数:34,代码来源:svgpath2code.cs


示例7: IsInsertionTrigger

 internal override bool IsInsertionTrigger(SourceText text, int characterPosition, OptionSet options)
 {
     var ch = text[characterPosition];
     return ch == ' ' ||
         (CompletionUtilities.IsStartingNewWord(text, characterPosition) &&
         options.GetOption(CompletionOptions.TriggerOnTypingLetters, LanguageNames.CSharp));
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:PartialTypeCompletionProvider.cs


示例8: Run

		public override void Run (IEnumerable<string> args)
		{
			string current_library = "";

			var options = new OptionSet () {
				{ "o|out=", 
					"{FILE} to generate/update documentation within.\n" + 
					"If not specified, will process " + file + ".\n" +
					"Set to '-' to skip updates and write to standard output.",
					v => file = v },
				{ "library=",
					"The {LIBRARY} that the following --type=TYPE types should be a part of.",
					v => current_library = v },
				{ "type=",
					"The full {TYPE} name of a type to copy into the output file.",
					v => AddTypeToLibrary (current_library, v) },
			};
			directories = Parse (options, args, "export-ecma-xml", 
					"[OPTIONS]+ DIRECTORIES",
					"Export mdoc documentation within DIRECTORIES into ECMA-format XML.\n\n" +
					"DIRECTORIES are mdoc(5) directories as produced by 'mdoc update'.");
			if (directories == null || directories.Count == 0)
				return;

			Update ();
		}
开发者ID:carrie901,项目名称:mono,代码行数:26,代码来源:ecmadoc.cs


示例9: AddIndentBlockOperations

        public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, OptionSet optionSet, NextAction<IndentBlockOperation> nextOperation)
        {
            nextOperation.Invoke(list);

            var queryExpression = node as QueryExpressionSyntax;
            if (queryExpression != null)
            {
                var firstToken = queryExpression.FromClause.Expression.GetFirstToken(includeZeroWidth: true);
                var lastToken = queryExpression.FromClause.Expression.GetLastToken(includeZeroWidth: true);
                AddIndentBlockOperation(list, queryExpression.FromClause.FromKeyword, firstToken, lastToken);

                for (int i = 0; i < queryExpression.Body.Clauses.Count; i++)
                {
                    // if it is nested query expression
                    var fromClause = queryExpression.Body.Clauses[i] as FromClauseSyntax;
                    if (fromClause != null)
                    {
                        firstToken = fromClause.Expression.GetFirstToken(includeZeroWidth: true);
                        lastToken = fromClause.Expression.GetLastToken(includeZeroWidth: true);
                        AddIndentBlockOperation(list, fromClause.FromKeyword, firstToken, lastToken);
                    }
                }

                // set alignment line for query expression
                var baseToken = queryExpression.GetFirstToken(includeZeroWidth: true);
                var endToken = queryExpression.GetLastToken(includeZeroWidth: true);
                if (!baseToken.IsMissing && !baseToken.Equals(endToken))
                {
                    var startToken = baseToken.GetNextToken(includeZeroWidth: true);
                    SetAlignmentBlockOperation(list, baseToken, startToken, endToken);
                }
            }
        }
开发者ID:noahstein,项目名称:roslyn,代码行数:33,代码来源:QueryExpressionFormattingRule.cs


示例10: Main

        public static void Main(string [] args)
        {
            // Parse the command line options
            bool show_help       = false;
            OptionSet option_set = new OptionSet () {
                { "v|version", _("Print version information"), v => { PrintVersion (); } },
                { "h|help", _("Show this help text"), v => show_help = v != null }
            };

            try {
                option_set.Parse (args);

            } catch (OptionException e) {
                Console.Write ("SparkleShare: ");
                Console.WriteLine (e.Message);
                Console.WriteLine ("Try `sparkleshare --help' for more information.");
            }

            if (show_help)
                ShowHelp (option_set);

            // Initialize the controller this way so that
            // there aren't any exceptions in the OS specific UI's
            Controller = new SparkleController ();
            Controller.Initialize ();

            if (Controller != null) {
                UI = new SparkleUI ();
                UI.Run ();
            }
        }
开发者ID:rayleyva,项目名称:SparkleShare,代码行数:31,代码来源:Program.cs


示例11: Main

    /// <summary>Parameters: num_files weight_1 .. weight_n file_1 .. file_n output_file</summary>
    /// <param name="args">the command-line arguments</param>
    public static void Main(string[] args)
    {
        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Handlers.UnhandledExceptionHandler);

        // parse command-line parameters

        string prediction_file = null;
        //string score_file      = null;
           	var p = new OptionSet() {
           			{ "data-dir=",              v => data_dir = v         },
            { "prediction-file=",       v => prediction_file = v  },
            { "sigmoid",                v => sigmoid = v != null  },
            { "pairwise-probability",   v => pairwise_prob = v != null   },
            { "pairwise-wins",          v => pairwise_wins = v != null   },
            { "rated-probability",      v => rated_prob = v != null      },
            { "constant-rating",        v => constant_rating = v != null },
            //{ "score-file=",            v => score_file = v },
           	  	};
           		IList<string> extra_args = p.Parse(args);

        string rated_file = extra_args[0];

        // combine files
        IList<double> test_scores;
        IList<double> validation_scores;

        if (constant_rating)
        {
            test_scores = ReadFile(rated_file);
            validation_scores = ReadFile(ValidationFilename(rated_file));
        }
        else
        {
            string rating_file = extra_args[1];
            test_scores = CombineFiles(rated_file, rating_file);
            validation_scores = CombineFiles(ValidationFilename(rated_file), ValidationFilename(rating_file));
        }

        // compute error on validation set
        string validation_candidates_file = Path.Combine(data_dir, "mml-track2/validationCandidatesIdx2.txt");
        string validation_hits_file       = Path.Combine(data_dir, "mml-track2/validationHitsIdx2.txt");
        var candidates = Track2Items.Read(validation_candidates_file);
        var hits       = Track2Items.Read(validation_hits_file);
        double error = KDDCup.EvaluateTrack2(Decide(validation_scores), candidates, hits);
        Console.WriteLine("ERR {0:F7}", error);

        if (prediction_file != null)
        {
            WritePredictions(Decide(test_scores), prediction_file);
            WritePredictions(Decide(validation_scores), ValidationFilename(prediction_file));
        }

        /*
        if (score_file != null)
        {
            WriteScores(test_scores, score_file);
            WriteScores(test_scores, ValidationFilename(score_file));
        }
        */
    }
开发者ID:zenogantner,项目名称:MML-KDD,代码行数:62,代码来源:KDDTrack2Composite.cs


示例12: Check

        /// <summary>
        /// Method performing the check command
        /// </summary>
        /// <param name="argsList">
        /// Command line like style
        /// </param>
        public static void Check(IEnumerable<string> argsList)
        {
            string outname = null;
            bool help = false;
            var op = new OptionSet() {
                {"check", "Command name, consumes token", v => int.Parse("0")},
                {"save|outname=", "Output of the tabulation filename", v => outname = v},
                {"help|h", "Shows this help message", v => help = true}
            };

            List<string> checkList = op.Parse(argsList);
            if (1 > checkList.Count || help) {
                Console.WriteLine ("Usage --check [--options] res-basis res-list...");
                op.WriteOptionDescriptions(Console.Out);
                return;
            }
            var list = new List<ResultSummary> ();
            var B = JsonConvert.DeserializeObject<ResultSummary> (File.ReadAllText (checkList [0]));
            foreach(string arg in checkList) {
                var R = JsonConvert.DeserializeObject<ResultSummary> (File.ReadAllText (arg));
                R.Parametrize (B);
                R.ResultName = arg;
                R.QueryList = null;
                list.Add (R);
                // Console.WriteLine (JsonConvert.SerializeObject(R, Formatting.Indented));
            }

            var s = JsonConvert.SerializeObject (list, Formatting.Indented);
            Console.WriteLine (s);
            if (outname != null) {
                File.WriteAllText(outname, s);
            }
        }
开发者ID:sadit,项目名称:natix,代码行数:39,代码来源:Commands.cs


示例13: Main

		static void Main(string[] args) {
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			try {
				// use command-line parameters if provided (used by auto-update functionality)
				bool showHelp = false;
				bool skipUpdateCheck = false;

				_options = new OptionSet {
			        {"h|help", "Show this short help text", v => showHelp = true},
			        {"k|killpid=", "Kill calling (old) process (to be used by updater)", KillDanglingProcess },
			        {"c|cleanupdate=", "Delete (old) executable (to be used by updater)", RemoveOldExecutable },
					{"s|skip-update-check", "Skip update check)", v => skipUpdateCheck = true },
			    };
				_options.Parse(args);
				if (showHelp) {
					ShowHelp();
					return;
				}

				Application.Run(new MainForm(skipUpdateCheck));
			}

			catch (Exception exc) {
				MessageBox.Show("An error ocurred: " + exc.Message + "\r\n\r\nCallstack: " + exc.StackTrace);
			}
		}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:28,代码来源:Program.cs


示例14: Help

 /// <summary>
 /// Display the help text for this command line program.
 /// </summary>
 /// <param name="os"></param>
 private void Help(OptionSet os)
 {
     Console.WriteLine("Usage: " + System.AppDomain.CurrentDomain.FriendlyName + " [-?|--help] [-iINPUT|--input=INPUT] [-oOUTPUT|--output=OUTPUT] [-sSTICKY|--sticky=STICKY] [-aSORTATTRIBUTES|--attributes=SORTATTRIBUTES]");
     Console.WriteLine();
     Console.WriteLine("Option:");
     os.WriteOptionDescriptions(Console.Out);
 }
开发者ID:LeCantaloop,项目名称:CsProjArrange,代码行数:11,代码来源:CsProjArrangeConsole.cs


示例15: CreateEngine

		internal static CacheIndentEngine CreateEngine(string text, out SourceText sourceText, OptionSet options = null)
		{
			if (options == null) {
				options = FormattingOptionsFactory.CreateMono ();
				//	options.AlignToFirstIndexerArgument = formatOptions.AlignToFirstMethodCallArgument = true;
			}

			var sb = new StringBuilder ();
			int offset = 0;
			for (int i = 0; i < text.Length; i++) {
				var ch = text [i];
				if (ch == '$') {
					offset = i;
					continue;
				}
				sb.Append (ch);
			}


			sourceText = SourceText.From (sb.ToString ());

			var result = new CacheIndentEngine (new CSharpIndentEngine (options));
			result.Update (sourceText, offset);
			return result;
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:25,代码来源:TextPasteIndentEngineTests.cs


示例16: BindCommadLineParameters

 public void BindCommadLineParameters(OptionSet optionSet)
 {
     optionSet
         .Add("i|include=", "Include files to the package", _includes.Add)
         .Add("o|output=", "Name of the output file", x => _outputFileName = x)
         .Add("cn=", "CN of the certificate", x => _cn = x);
 }
开发者ID:kbulte,项目名称:PackMan,代码行数:7,代码来源:CreatePackageAction.cs


示例17: ShowHelp

 static void ShowHelp(OptionSet p)
 {
     Console.WriteLine("Usage: omnisharp -s /path/to/sln [-p PortNumber]");
     Console.WriteLine();
     Console.WriteLine("Options:");
     p.WriteOptionDescriptions(Console.Out);
 }
开发者ID:jaburns,项目名称:OmniSharpServer,代码行数:7,代码来源:Program.cs


示例18: Main

        public static void Main(string[] args)
        {
            var showHelp = false;

            var options = new OptionSet()
            {
                {
                    "h|help",
                    "show this message and exit",
                    v => showHelp = v != null
                    },
            };

            List<string> extras;

            try
            {
                extras = options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("{0}: ", GetExecutableName());
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName());
                return;
            }

            if (extras.Count < 1 || extras.Count > 2 ||
                showHelp == true)
            {
                Console.WriteLine("Usage: {0} [OPTIONS]+ input_cnd [output_file]", GetExecutableName());
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            var inputPath = extras[0];
            var outputPath = extras.Count > 1 ? extras[1] : null;

            var cnd = new ConditionalsFile();
            using (var input = File.OpenRead(inputPath))
            {
                cnd.Deserialize(input);
            }

            if (outputPath == null)
            {
                DumpConditionals(Console.Out, cnd);
            }
            else
            {
                using (var output = File.Create(outputPath))
                {
                    var writer = new StreamWriter(output);
                    DumpConditionals(writer, cnd);
                    writer.Flush();
                }
            }
        }
开发者ID:rjbarroso,项目名称:Gibbed.MassEffect3,代码行数:60,代码来源:Program.cs


示例19: Main

        public static void Main(string[] args)
        {
            var sgopts = new StubGenOptions ();
            var opts = new OptionSet () {
                { "o=|output-dir=", "Directory to generate classes in. Defaults to current directory", v => sgopts.OutputDir = v },
                { "no-header", "Do not put header with license in generated files", v => sgopts.NoHeader = true },
                { "l|license=", "Name of the license or path to a text file with license text (defaults to MIT/X11)", v => sgopts.LicenseName = v },
                { "a|author=", "Author name", v => sgopts.AuthorName = v },
                { "e|email=", "Author email", v => sgopts.AuthorEmail = v },
                { "c|copyright=", "Copyright holder", v => sgopts.CopyrightHolder = v },
                { "f|force|overwrite-all", "Overwrite all files without prompting.", v => sgopts.OverwriteAll = true },
                { "d|debug", "Show more information on errors.", v => sgopts.Debug = true },
                { "p|private|non-public", "Include private/internal members in the outline.", v => sgopts.IncludeNonPublic = true },
                { "h|help|?", "Show this help screen", v => sgopts.ShowHelp = true }
            };

            if (sgopts.ShowHelp)
                ShowHelp (opts);

            List <string> assemblies = opts.Parse (args);
            if (assemblies == null || assemblies.Count == 0)
                ShowHelp (opts);

            foreach (string ap in assemblies)
                ProcessAssembly (ap, sgopts);
        }
开发者ID:grendello,项目名称:StubGen,代码行数:26,代码来源:Main.cs


示例20: Main

        private static void Main(string[] args)
        {
            IStatCalculator stats = null;
            bool showErrors = true;
            bool showHelp = false;

            var p = new OptionSet
            {
                { "b|burndown", "Get burndown chart data", v => {
                    stats = new BurndownStats();
                }},
                { "c|cfd", "Get cumulative flow chart data", v => { stats = new CumulativeFlowStats(); }},
                { "t|table", "Summarize issues in sprint", v => { stats = new ContentTableStats(); }},
                { "e|errors", "Turn on or off list of issues with state errors (defaults to on)",
                    v => { showErrors = v != null; } },
                { "h|?|help", "Display this help message", v => showHelp = v != null }
            };
            List<String> extras = p.Parse(args);

            if (showHelp)
            {
                ShowHelp(p);
                return;
            }

            IList<Tuple<string, string>> repos = GetRepoNames(extras);

            if (stats == null)
            {
                stats = new BurndownStats();
            }

            var program = new Program(stats, repos, showErrors);
            program.Go();
        }
开发者ID:christav,项目名称:GHSprintTrax,代码行数:35,代码来源:Program.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OptionType类代码示例发布时间:2022-05-24
下一篇:
C# OptionKey类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap