本文整理汇总了C#中VariableDictionary类的典型用法代码示例。如果您正苦于以下问题:C# VariableDictionary类的具体用法?C# VariableDictionary怎么用?C# VariableDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableDictionary类属于命名空间,在下文中一共展示了VariableDictionary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CalamariVariableDictionary
public CalamariVariableDictionary(string storageFilePath, string sensitiveFilePath, string sensitiveFilePassword)
{
var fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem();
if (!string.IsNullOrEmpty(storageFilePath))
{
if (!fileSystem.FileExists(storageFilePath))
throw new CommandException("Could not find variables file: " + storageFilePath);
var nonSensitiveVariables = new VariableDictionary(storageFilePath);
nonSensitiveVariables.GetNames().ForEach(name => Set(name, nonSensitiveVariables.GetRaw(name)));
}
if (!string.IsNullOrEmpty(sensitiveFilePath))
{
var rawVariables = string.IsNullOrWhiteSpace(sensitiveFilePassword)
? fileSystem.ReadFile(sensitiveFilePath)
: Decrypt(fileSystem.ReadAllBytes(sensitiveFilePath), sensitiveFilePassword);
try
{
var sensitiveVariables = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawVariables);
foreach (var variable in sensitiveVariables)
{
SetSensitive(variable.Key, variable.Value);
}
}
catch (JsonReaderException)
{
throw new CommandException("Unable to parse sensitive-variables as valid JSON.");
}
}
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:34,代码来源:CalamariVariableDictionary.cs
示例2: SetOutputVariable
void SetOutputVariable(string name, string value, VariableDictionary variables)
{
if (variables.Get(name) != value)
{
Log.SetOutputVariable(name, value, variables);
}
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:7,代码来源:AzurePowershellContext.cs
示例3: ReplaceAppSettingOrConnectionString
static IEnumerable<string> ReplaceAppSettingOrConnectionString(XNode document, string xpath, string keyAttributeName, string keyAttributeValue, string valueAttributeName, VariableDictionary variables)
{
var changes = new List<string>();
var settings = (
from element in document.XPathSelectElements(xpath)
let keyAttribute = element.Attribute(keyAttributeName)
where keyAttribute != null
where string.Equals(keyAttribute.Value, keyAttributeValue, StringComparison.InvariantCultureIgnoreCase)
select element).ToList();
if (settings.Count == 0)
return changes;
var value = variables.Get(keyAttributeValue) ?? string.Empty;
foreach (var setting in settings)
{
changes.Add(string.Format("Setting '{0}' = '{1}'", keyAttributeValue, value));
var valueAttribute = setting.Attribute(valueAttributeName);
if (valueAttribute == null)
{
setting.Add(new XAttribute(valueAttributeName, value));
}
else
{
valueAttribute.SetValue(value);
}
}
return changes;
}
开发者ID:merbla,项目名称:Calamari,代码行数:32,代码来源:ConfigurationVariablesReplacer.cs
示例4: Execute
public override int Execute(string[] commandLineArguments)
{
Options.Parse(commandLineArguments);
Guard.NotNullOrWhiteSpace(packageFile, "No package file was specified. Please pass -cspkg YourPackage.cspkg");
if (!File.Exists(packageFile))
throw new CommandException("Could not find package file: " + packageFile);
var variables = new VariableDictionary();
variables.Set(SpecialVariables.Action.Azure.CloudServicePackagePath, packageFile);
variables.Set(SpecialVariables.OriginalPackageDirectoryPath, !string.IsNullOrWhiteSpace(destinationDirectory) ? destinationDirectory : Path.GetDirectoryName(packageFile));
var fileSystem = new WindowsPhysicalFileSystem();
var conventions = new List<IConvention>
{
new EnsureCloudServicePackageIsCtpFormatConvention(fileSystem),
new ExtractAzureCloudServicePackageConvention(fileSystem),
};
var deployment = new RunningDeployment(packageFile, variables);
var conventionRunner = new ConventionProcessor(deployment, conventions);
conventionRunner.RunConventions();
return 0;
}
开发者ID:sergio,项目名称:Calamari,代码行数:27,代码来源:ExtractAzureCloudServicePackageCommand.cs
示例5: Deploy
public void Deploy()
{
OctopusTestAzureSubscription.IgnoreIfCertificateNotInstalled();
var nugetPackageFile = PackageBuilder.BuildSamplePackage("Octopus.Sample.AzureCloudService", "1.0.0");
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
OctopusTestAzureSubscription.PopulateVariables(variables);
OctopusTestCloudService.PopulateVariables(variables);
variables.Set(SpecialVariables.Action.Azure.Slot, "Staging");
variables.Set(SpecialVariables.Action.Azure.SwapIfPossible, false.ToString());
variables.Set(SpecialVariables.Action.Azure.UseCurrentInstanceCount, false.ToString());
variables.Set(SpecialVariables.Action.Name, "AzureCloudService");
variables.Set(SpecialVariables.Release.Number, "1.0.0");
// Disable cspkg extraction
variables.Set(SpecialVariables.Action.Azure.CloudServicePackageExtractionDisabled, true.ToString());
fileSystem = new WindowsPhysicalFileSystem();
stagingDirectory = Path.GetTempPath();
variables.Set(SpecialVariables.Action.Azure.PackageExtractionPath, stagingDirectory);
variables.Save(variablesFile);
result = Invoke(
Calamari()
.Action("deploy-azure-cloud-service")
.Argument("package", nugetPackageFile)
.Argument("variables", variablesFile));
}
开发者ID:enlightendesigns,项目名称:Calamari,代码行数:32,代码来源:DeployAzureCloudServiceSansPackageExtractionFixture.cs
示例6: OctopusConfigurationProviderTests
public OctopusConfigurationProviderTests()
{
Options = new OctopusConfigurationProviderOptions();
VariableDictionaryProvider = new Mock<IVariableDictionaryProvider>();
VariableDictionary = new VariableDictionary();
VariableDictionaryProvider.Setup(value => value.Get(Options)).Returns(VariableDictionary);
}
开发者ID:gusztavvargadr,项目名称:aspnet-Configuration.Contrib,代码行数:7,代码来源:OctopusConfigurationProviderTests.cs
示例7: SetUp
public void SetUp()
{
variables = new VariableDictionary();
variables.Set(SpecialVariables.OriginalPackageDirectoryPath, stagingDirectory);
fileSystem = Substitute.For<ICalamariFileSystem>();
deployment = new RunningDeployment(packageFilePath, variables);
}
开发者ID:sergio,项目名称:Calamari,代码行数:7,代码来源:CopyPackageToCustomInstallationDirectoryConventionFixture.cs
示例8: Invoke
protected CalamariResult Invoke(CommandLine command, VariableDictionary variables)
{
var capture = new CaptureCommandOutput();
var runner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables), capture));
var result = runner.Execute(command.Build());
return new CalamariResult(result.ExitCode, capture);
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:7,代码来源:CalamariFixture.cs
示例9: AddVariables
static void AddVariables(VariableDictionary variableDictionary, IDictionary<string, string> items)
{
foreach (var variableName in items.Keys)
{
variableDictionary.Set(variableName, items[variableName]);
}
}
开发者ID:NoesisLabs,项目名称:Calamari,代码行数:7,代码来源:SensitiveVariables.cs
示例10: SetUp
public void SetUp()
{
fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem();
// Ensure tenticle directory exists
tentacleDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestTentacle");
var tentacleHiddenDirectory = Path.Combine(tentacleDirectory, ".tentacle");
fileSystem.EnsureDirectoryExists(tentacleDirectory);
fileSystem.EnsureDirectoryExists(tentacleHiddenDirectory);
fileSystem.PurgeDirectory(tentacleHiddenDirectory, FailureOptions.ThrowOnFailure);
Environment.SetEnvironmentVariable("TentacleJournal", Path.Combine(tentacleHiddenDirectory, "DeploymentJournal.xml" ));
variables = new VariableDictionary();
variables.EnrichWithEnvironmentVariables();
deploymentJournal = new DeploymentJournal(fileSystem, new SystemSemaphore(), variables);
packagesDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestPackages");
fileSystem.EnsureDirectoryExists(packagesDirectory);
stagingDirectory = Path.Combine(Path.GetTempPath(), "CalamariTestStaging");
fileSystem.EnsureDirectoryExists(stagingDirectory);
// Create some artificats
const string retentionPolicySet1 = "retentionPolicySet1";
CreateDeployment(Path.Combine(packagesDirectory, "Acme.1.0.0.nupkg"), Path.Combine(stagingDirectory, "Acme.1.0.0"),
new DateTimeOffset(new DateTime(2015, 01, 26), new TimeSpan(10, 0,0)), retentionPolicySet1);
CreateDeployment(Path.Combine(packagesDirectory, "Acme.1.1.0.nupkg"), Path.Combine(stagingDirectory, "Acme.1.1.0"),
new DateTimeOffset(new DateTime(2015, 02, 01), new TimeSpan(10, 0,0)), retentionPolicySet1);
CreateDeployment(Path.Combine(packagesDirectory, "Acme.1.2.0.nupkg"), Path.Combine(stagingDirectory, "Acme.1.2.0"),
new DateTimeOffset(new DateTime(2015, 02, 10), new TimeSpan(10, 0,0)), retentionPolicySet1);
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:35,代码来源:CleanFixture.cs
示例11: 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;
}
开发者ID:NoesisLabs,项目名称:Calamari,代码行数:60,代码来源:DeployAzureCloudServiceCommand.cs
示例12: UpdateConfigurationSettings
static void UpdateConfigurationSettings(XContainer configurationFile, VariableDictionary variables)
{
Log.Verbose("Updating configuration settings...");
var foundSettings = false;
WithConfigurationSettings(configurationFile, (roleName, settingName, settingValueAttribute) =>
{
var setting = variables.Get(roleName + "/" + settingName) ??
variables.Get(roleName + "\\" + settingName) ??
variables.Get(settingName) ??
(variables.GetNames().Contains(settingName) ? "" : null);
if (setting != null)
{
foundSettings = true;
Log.Info("Updating setting for role {0}: {1} = {2}", roleName, settingName, setting);
settingValueAttribute.Value = setting;
}
});
if (!foundSettings)
{
Log.Info("No settings that match provided variables were found.");
}
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:25,代码来源:ConfigureAzureCloudServiceConvention.cs
示例13: PerformSubstitution
public void PerformSubstitution(string sourceFile, VariableDictionary variables, string targetFile)
{
var source = fileSystem.ReadFile(sourceFile);
var encoding = GetEncoding(sourceFile, variables);
var result = variables.Evaluate(source);
fileSystem.OverwriteFile(targetFile, result, encoding);
}
开发者ID:enlightendesigns,项目名称:Calamari,代码行数:7,代码来源:FileSubstituter.cs
示例14: PerformSubstitution
public void PerformSubstitution(string sourceFile, VariableDictionary variables, string targetFile)
{
var source = File.ReadAllText(sourceFile);
var result = variables.Evaluate(source);
File.WriteAllText(targetFile, result);
}
开发者ID:sergio,项目名称:Calamari,代码行数:7,代码来源:FileSubstituter.cs
示例15: BuildPath
private static string BuildPath(string site, VariableDictionary variables)
{
var relativePath = (variables.Get(SpecialVariables.Action.Azure.PhysicalPath) ?? "").TrimStart('\\');
return relativePath != ""
? site + "\\" + relativePath
: site;
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:8,代码来源:AzureWebAppConvention.cs
示例16: GetInitialExtractionDirectory
private string GetInitialExtractionDirectory(VariableDictionary variables)
{
var root = GetApplicationDirectoryPath(variables);
root = AppendEnvironmentNameIfProvided(variables, root);
fileSystem.EnsureDirectoryExists(root);
fileSystem.EnsureDiskHasEnoughFreeSpace(root);
return root;
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:9,代码来源:ExtractPackageToApplicationDirectoryConvention.cs
示例17: SetUp
public void SetUp()
{
fileSystem = Substitute.For<ICalamariFileSystem>();
variables = new VariableDictionary();
variables.Set(SpecialVariables.OriginalPackageDirectoryPath, StagingDirectory);
deployment = new RunningDeployment(StagingDirectory, variables);
convention = new ChooseCloudServiceConfigurationFileConvention(fileSystem);
}
开发者ID:NoesisLabs,项目名称:Calamari,代码行数:9,代码来源:ChooseAzureCloudServiceConfigurationFileConventionFixture.cs
示例18: SetOutputVariable
public static void SetOutputVariable(string name, string value, VariableDictionary variables)
{
Info(String.Format("##octopus[setVariable name=\"{0}\" value=\"{1}\"]",
ConvertServiceMessageValue(name),
ConvertServiceMessageValue(value)));
if (variables != null)
variables.SetOutputVariable(name, value);
}
开发者ID:sergio,项目名称:Calamari,代码行数:9,代码来源:Log.cs
示例19: PopulateVariables
public static void PopulateVariables(VariableDictionary variables)
{
var certificate = GetCertificate();
variables.Set(SpecialVariables.Account.Name, "OctopusAzureTestAccount");
variables.Set(SpecialVariables.Account.AccountType, "AzureSubscription");
variables.Set(SpecialVariables.Action.Azure.CertificateBytes, Convert.ToBase64String(certificate.Export(X509ContentType.Pfx)));
variables.Set(SpecialVariables.Action.Azure.CertificateThumbprint, CertificateThumbprint);
variables.Set(SpecialVariables.Action.Azure.SubscriptionId, AzureSubscriptionId);
}
开发者ID:bjewell52,项目名称:Calamari,代码行数:10,代码来源:OctopusTestAzureSubscription.cs
示例20: AddEnvironmentVariables
private VariableDictionary AddEnvironmentVariables()
{
var variables = new VariableDictionary();
var convention = new ContributeEnvironmentVariablesConvention();
convention.Install(new RunningDeployment("C:\\Package.nupkg", variables));
Assert.That(variables.GetNames().Count, Is.GreaterThan(3));
Assert.That(variables.GetRaw(SpecialVariables.Tentacle.Agent.InstanceName), Is.EqualTo("#{env:TentacleInstanceName}"));
return variables;
}
开发者ID:sergio,项目名称:Calamari,代码行数:10,代码来源:ContributeEnvironmentVariablesFixture.cs
注:本文中的VariableDictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论