本文整理汇总了C#中VariableDictionary.GetFlag方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDictionary.GetFlag方法的具体用法?C# VariableDictionary.GetFlag怎么用?C# VariableDictionary.GetFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableDictionary
的用法示例。
在下文中一共展示了VariableDictionary.GetFlag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override int Execute(string[] commandLineArguments)
{
Options.Parse(commandLineArguments);
Guard.NotNullOrWhiteSpace(packageFile, "No package file was specified. Please pass --package YourPackage.nupkg");
if (!File.Exists(packageFile))
throw new CommandException("Could not find package file: " + packageFile);
if (variablesFile != null && !File.Exists(variablesFile))
throw new CommandException("Could not find variables file: " + variablesFile);
Log.Info("Deploying package: " + packageFile);
if (variablesFile != null)
Log.Info("Using variables from: " + variablesFile);
var variables = new VariableDictionary(variablesFile);
var fileSystem = new WindowsPhysicalFileSystem();
var embeddedResources = new ExecutingAssemblyEmbeddedResources();
var scriptEngine = new CombinedScriptEngine();
var commandLineRunner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));
var azurePackageUploader = new AzurePackageUploader();
var certificateStore = new CalamariCertificateStore();
var cloudCredentialsFactory = new SubscriptionCloudCredentialsFactory(certificateStore);
var cloudServiceConfigurationRetriever = new AzureCloudServiceConfigurationRetriever();
var substituter = new FileSubstituter();
var configurationTransformer = new ConfigurationTransformer(variables.GetFlag(SpecialVariables.Package.IgnoreConfigTransformationErrors), variables.GetFlag(SpecialVariables.Package.SuppressConfigTransformationLogging));
var replacer = new ConfigurationVariablesReplacer();
var conventions = new List<IConvention>
{
new ContributeEnvironmentVariablesConvention(),
new LogVariablesConvention(),
new ExtractPackageToStagingDirectoryConvention(new LightweightPackageExtractor(), fileSystem),
new FindCloudServicePackageConvention(fileSystem),
new EnsureCloudServicePackageIsCtpFormatConvention(fileSystem),
new ExtractAzureCloudServicePackageConvention(fileSystem),
new ChooseCloudServiceConfigurationFileConvention(fileSystem),
new ConfiguredScriptConvention(DeploymentStages.PreDeploy, scriptEngine, fileSystem, commandLineRunner),
new PackagedScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner),
new ConfigureAzureCloudServiceConvention(fileSystem, cloudCredentialsFactory, cloudServiceConfigurationRetriever),
new SubstituteInFilesConvention(fileSystem, substituter),
new ConfigurationTransformsConvention(fileSystem, configurationTransformer),
new ConfigurationVariablesConvention(fileSystem, replacer),
new PackagedScriptConvention(DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner),
new ConfiguredScriptConvention(DeploymentStages.Deploy, scriptEngine, fileSystem, commandLineRunner),
new RePackageCloudServiceConvention(fileSystem),
new UploadAzureCloudServicePackageConvention(fileSystem, azurePackageUploader, cloudCredentialsFactory),
new DeployAzureCloudServicePackageConvention(fileSystem, embeddedResources, scriptEngine, commandLineRunner),
new PackagedScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner),
new ConfiguredScriptConvention(DeploymentStages.PostDeploy, scriptEngine, fileSystem, commandLineRunner),
};
var deployment = new RunningDeployment(packageFile, variables);
var conventionRunner = new ConventionProcessor(deployment, conventions);
conventionRunner.RunConventions();
return 0;
}
示例2: UpdateConfigurationWithCurrentInstanceCount
void UpdateConfigurationWithCurrentInstanceCount(XContainer localConfigurationFile, string configurationFileName, VariableDictionary variables)
{
if (!variables.GetFlag(SpecialVariables.Action.Azure.UseCurrentInstanceCount))
return;
var serviceName = variables.Get(SpecialVariables.Action.Azure.CloudServiceName);
var slot = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), variables.Get(SpecialVariables.Action.Azure.Slot));
var remoteConfigurationFile = configurationRetriever.GetConfiguration(
credentialsFactory.GetCredentials(variables.Get(SpecialVariables.Action.Azure.SubscriptionId),
variables.Get(SpecialVariables.Action.Azure.CertificateThumbprint),
variables.Get(SpecialVariables.Action.Azure.CertificateBytes)),
serviceName,
slot);
if (remoteConfigurationFile == null)
{
Log.Info("There is no current deployment of service '{0}' in slot '{1}', so existing instance counts will not be imported.", serviceName, slot);
return;
}
var rolesByCount = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Log.Verbose("Local instance counts (from " + Path.GetFileName(configurationFileName) + "): ");
WithInstanceCounts(localConfigurationFile, (roleName, attribute) =>
{
Log.Verbose(" - " + roleName + " = " + attribute.Value);
string value;
if (rolesByCount.TryGetValue(roleName, out value))
{
attribute.SetValue(value);
}
});
Log.Verbose("Remote instance counts: ");
WithInstanceCounts(remoteConfigurationFile, (roleName, attribute) =>
{
rolesByCount[roleName] = attribute.Value;
Log.Verbose(" - " + roleName + " = " + attribute.Value);
});
Log.Verbose("Replacing local instance count settings with remote settings: ");
WithInstanceCounts(localConfigurationFile, (roleName, attribute) =>
{
string value;
if (!rolesByCount.TryGetValue(roleName, out value))
return;
attribute.SetValue(value);
Log.Verbose(" - " + roleName + " = " + attribute.Value);
});
}
示例3: DeploymentSyncOptions
private static DeploymentSyncOptions DeploymentSyncOptions(VariableDictionary variables)
{
var syncOptions = new DeploymentSyncOptions
{
WhatIf = false,
UseChecksum = true,
DoNotDelete = !variables.GetFlag(SpecialVariables.Action.Azure.RemoveAdditionalFiles),
};
ApplyAppOfflineDeploymentRule(syncOptions, variables);
ApplyPreserveAppDataDeploymentRule(syncOptions, variables);
ApplyPreservePathsDeploymentRule(syncOptions, variables);
return syncOptions;
}
示例4: ApplyAppOfflineDeploymentRule
private static void ApplyAppOfflineDeploymentRule(DeploymentSyncOptions syncOptions, VariableDictionary variables)
{
if (variables.GetFlag(SpecialVariables.Action.Azure.AppOffline))
{
var rules = Microsoft.Web.Deployment.DeploymentSyncOptions.GetAvailableRules();
DeploymentRule rule;
if (rules.TryGetValue("AppOffline", out rule))
{
syncOptions.Rules.Add(rule);
}
else
{
Log.Verbose("Azure Deployment API does not support `AppOffline` deployment rule.");
}
}
}
示例5: ApplyPreserveAppDataDeploymentRule
private static void ApplyPreserveAppDataDeploymentRule(DeploymentSyncOptions syncOptions, VariableDictionary variables)
{
// If PreserveAppData variable set, then create SkipDelete rules for App_Data directory
if (variables.GetFlag(SpecialVariables.Action.Azure.PreserveAppData))
{
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDataFiles", "Delete", "filePath", "\\\\App_Data\\\\.*", null));
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDataDir", "Delete", "dirPath", "\\\\App_Data(\\\\.*|$)", null));
}
}
示例6: DeploymentSyncOptions
private static DeploymentSyncOptions DeploymentSyncOptions(VariableDictionary variables)
{
var syncOptions = new DeploymentSyncOptions
{
WhatIf = false,
UseChecksum = true,
DoNotDelete = !variables.GetFlag(SpecialVariables.Action.Azure.RemoveAdditionalFiles, false)
};
// If PreserveAppData variable set, then create SkipDelete rules for App_Data directory
if (variables.GetFlag(SpecialVariables.Action.Azure.PreserveAppData, false))
{
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDataFiles", "Delete", "filePath", "\\\\App_Data\\\\.*", null));
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDataDir", "Delete", "dirPath", "\\\\App_Data(\\\\.*|$)", null));
}
// If PreservePaths variable set, then create SkipDelete rules for each path regex
var preservePaths = variables.GetStrings(SpecialVariables.Action.Azure.PreservePaths, ';');
if (preservePaths != null)
{
for (var i = 0; i < preservePaths.Count; i++)
{
var path = preservePaths[i];
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteFiles_" + i, "Delete", "filePath", path, null));
syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDir_" + i, "Delete", "dirPath", path, null));
}
}
return syncOptions;
}