本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.IsTrue方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.IsTrue方法的具体用法?C# NameValueCollection.IsTrue怎么用?C# NameValueCollection.IsTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.IsTrue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyAppSettings
private static void ApplyAppSettings(NameValueCollection appSettings, BootstrapperOptions options)
{
if (appSettings.IsTrue(AppSettingKeys.PreferNuget))
{
options.PreferNuget = true;
}
if (appSettings.IsTrue(AppSettingKeys.ForceNuget))
{
options.ForceNuget = true;
}
}
示例2: EvaluateDownloadOptions
private static IEnumerable<string> EvaluateDownloadOptions(DownloadArguments downloadArguments, IEnumerable<string> args, NameValueCollection appSettings, IDictionary envVariables, bool magicMode)
{
var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var target = magicMode ? GetMagicModeTarget() : Path.Combine(folder, "paket.exe");
string nugetSource = downloadArguments.NugetSource;
var appSettingsVersion = appSettings.GetKey(AppSettingKeys.PaketVersion);
var latestVersion = appSettingsVersion ?? envVariables.GetKey(EnvArgs.PaketVersionEnv) ?? downloadArguments.LatestVersion;
var appSettingsRequestPrerelease = appSettings.IsTrue(AppSettingKeys.Prerelease);
var prerelease = (appSettingsRequestPrerelease && string.IsNullOrEmpty(latestVersion)) || !downloadArguments.IgnorePrerelease;
bool doSelfUpdate = downloadArguments.DoSelfUpdate;
var ignoreCache = downloadArguments.IgnoreCache;
var commandArgs = args.ToList();
int? maxFileAgeInMinutes = downloadArguments.MaxFileAgeInMinutes;
if (commandArgs.Contains(CommandArgs.SelfUpdate))
{
commandArgs.Remove(CommandArgs.SelfUpdate);
doSelfUpdate = true;
}
var nugetSourceArg = commandArgs.SingleOrDefault(x => x.StartsWith(CommandArgs.NugetSourceArgPrefix));
if (nugetSourceArg != null)
{
commandArgs = commandArgs.Where(x => !x.StartsWith(CommandArgs.NugetSourceArgPrefix)).ToList();
nugetSource = nugetSourceArg.Substring(CommandArgs.NugetSourceArgPrefix.Length);
}
if (commandArgs.Contains(CommandArgs.IgnoreCache))
{
commandArgs.Remove(CommandArgs.IgnoreCache);
ignoreCache = true;
}
var maxFileAgeArg = commandArgs.SingleOrDefault(x => x.StartsWith(CommandArgs.MaxFileAge, StringComparison.Ordinal));
if (maxFileAgeArg != null)
{
var parts = maxFileAgeArg.Split("=".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 2)
{
var maxFileAgeInMinutesCommandArg = parts[1];
int parsedMaxFileAgeInMinutesCommandArg;
if (int.TryParse(maxFileAgeInMinutesCommandArg, out parsedMaxFileAgeInMinutesCommandArg))
maxFileAgeInMinutes = parsedMaxFileAgeInMinutesCommandArg;
}
commandArgs.Remove(maxFileAgeArg);
}
if (commandArgs.Count >= 1)
{
if (commandArgs[0] == CommandArgs.Prerelease)
{
prerelease = true;
latestVersion = String.Empty;
commandArgs.Remove(CommandArgs.Prerelease);
}
else
{
prerelease = false;
latestVersion = commandArgs[0];
commandArgs.Remove(commandArgs[0]);
}
}
downloadArguments.LatestVersion = latestVersion;
downloadArguments.IgnorePrerelease = !prerelease;
downloadArguments.IgnoreCache = ignoreCache;
downloadArguments.NugetSource = nugetSource;
downloadArguments.DoSelfUpdate = doSelfUpdate;
downloadArguments.Target = target;
downloadArguments.Folder = Path.GetDirectoryName(target);
if (magicMode)
{
if (appSettingsRequestPrerelease || !String.IsNullOrWhiteSpace(appSettingsVersion))
downloadArguments.MaxFileAgeInMinutes = 0;
else
downloadArguments.MaxFileAgeInMinutes = 60 * 12;
}
else
downloadArguments.MaxFileAgeInMinutes = maxFileAgeInMinutes;
return commandArgs;
}
示例3: FillOptionsFromAppSettings
private static void FillOptionsFromAppSettings(BootstrapperOptions options, NameValueCollection appSettings)
{
if (appSettings.IsTrue(AppSettingKeys.PreferNuget))
{
options.PreferNuget = true;
}
if (appSettings.IsTrue(AppSettingKeys.ForceNuget))
{
options.ForceNuget = true;
}
var latestVersion = appSettings.GetKey(AppSettingKeys.PaketVersion);
if (latestVersion != null)
{
options.DownloadArguments.LatestVersion = latestVersion;
}
if (appSettings.IsTrue(AppSettingKeys.Prerelease))
{
options.DownloadArguments.IgnorePrerelease = false;
}
}