Exemple #1
0
		private void SetOptionsFromXml()
		{
			var doc = XDocument.Parse(_searchOptionsResource);
			foreach (var f in doc.Descendants("searchoption"))
			{
				var longArg = f.Attributes("long").First().Value;
				var shortArg = f.Attributes("short").First().Value;
				var desc = f.Value.Trim();
				if (ArgActionDictionary.ContainsKey(longArg))
				{
					var option = new SearchArgOption(shortArg, longArg, ArgActionDictionary[longArg], desc);
					Options.Add(option);
					ArgDictionary.Add(longArg, option);
					if (!string.IsNullOrWhiteSpace(shortArg))
					{
						ArgDictionary.Add(shortArg, option);
					}
				}
				else if (BoolFlagActionDictionary.ContainsKey(longArg))
				{
					var option = new SearchFlagOption(shortArg, longArg, BoolFlagActionDictionary[longArg], desc);
					Options.Add(option);
					FlagDictionary.Add(longArg, option);
					if (!string.IsNullOrWhiteSpace(shortArg))
					{
						FlagDictionary.Add(shortArg, option);
					}
				}
			}
		}
Exemple #2
0
        private void SetOptionsFromXml()
        {
            var doc = XDocument.Parse(_searchOptionsResource);

            foreach (var f in doc.Descendants("searchoption"))
            {
                var longArg  = f.Attributes("long").First().Value;
                var shortArg = f.Attributes("short").First().Value;
                var desc     = f.Value.Trim();
                if (ArgActionDictionary.ContainsKey(longArg))
                {
                    var option = new SearchArgOption(shortArg, longArg, ArgActionDictionary[longArg], desc);
                    Options.Add(option);
                    ArgDictionary.Add(longArg, option);
                    if (!string.IsNullOrWhiteSpace(shortArg))
                    {
                        ArgDictionary.Add(shortArg, option);
                    }
                }
                else if (BoolFlagActionDictionary.ContainsKey(longArg))
                {
                    var option = new SearchFlagOption(shortArg, longArg, BoolFlagActionDictionary[longArg], desc);
                    Options.Add(option);
                    FlagDictionary.Add(longArg, option);
                    if (!string.IsNullOrWhiteSpace(shortArg))
                    {
                        FlagDictionary.Add(shortArg, option);
                    }
                }
            }
        }
Exemple #3
0
        private void SetOptionsFromJson()
        {
            var searchOptionsDict = JsonSerializer.Deserialize <SearchOptionsDictionary>(_searchOptionsResource);
            var optionDicts       = searchOptionsDict["searchoptions"];

            foreach (var optionDict in optionDicts)
            {
                var longArg  = optionDict["long"];
                var shortArg = optionDict.ContainsKey("short") ? optionDict["short"] : null;
                var desc     = optionDict["desc"];
                if (ArgActionDictionary.ContainsKey(longArg))
                {
                    var option = new SearchArgOption(shortArg, longArg, ArgActionDictionary[longArg], desc);
                    Options.Add(option);
                    ArgDictionary.Add(longArg, option);
                    if (!string.IsNullOrWhiteSpace(shortArg))
                    {
                        ArgDictionary.Add(shortArg, option);
                    }
                }
                else if (BoolFlagActionDictionary.ContainsKey(longArg))
                {
                    var option = new SearchFlagOption(shortArg, longArg, BoolFlagActionDictionary[longArg], desc);
                    Options.Add(option);
                    FlagDictionary.Add(longArg, option);
                    if (!string.IsNullOrWhiteSpace(shortArg))
                    {
                        FlagDictionary.Add(shortArg, option);
                    }
                }
            }
        }