当前位置: 首页>>代码示例>>C#>>正文


C# VariableDictionary.Get方法代码示例

本文整理汇总了C#中VariableDictionary.Get方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDictionary.Get方法的具体用法?C# VariableDictionary.Get怎么用?C# VariableDictionary.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VariableDictionary的用法示例。


在下文中一共展示了VariableDictionary.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例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);
            });
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:53,代码来源:ConfigureAzureCloudServiceConvention.cs

示例3: CreateAzureCertificate

        private string CreateAzureCertificate(string workingDirectory, VariableDictionary variables)
        {
            var certificateFilePath = Path.Combine(workingDirectory, CertificateFileName);
            var certificatePassword = GenerateCertificatePassword();
            var azureCertificate = certificateStore.GetOrAdd(
                variables.Get(SpecialVariables.Action.Azure.CertificateThumbprint),
                variables.Get(SpecialVariables.Action.Azure.CertificateBytes),
                StoreName.My);

            variables.Set("OctopusAzureCertificateFileName", certificateFilePath);
            variables.Set("OctopusAzureCertificatePassword", certificatePassword);

            fileSystem.WriteAllBytes(certificateFilePath, azureCertificate.Export(X509ContentType.Pfx, certificatePassword));
            return certificateFilePath;
        }
开发者ID:elevate,项目名称:Calamari,代码行数:15,代码来源:AzurePowershellContext.cs

示例4: 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

示例5: 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

示例6: 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

示例7: AppendEnvironmentNameIfProvided

        string AppendEnvironmentNameIfProvided(VariableDictionary variables, string root)
        {
            var environment = variables.Get(SpecialVariables.Environment.Name);
            if (!string.IsNullOrWhiteSpace(environment))
            {
                environment = fileSystem.RemoveInvalidFileNameChars(environment);
                root = Path.Combine(root, environment);
            }

            return root;
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:11,代码来源:ExtractPackageToApplicationDirectoryConvention.cs

示例8: GetApplicationDirectoryPath

        string GetApplicationDirectoryPath (VariableDictionary variables)
        {
            const string windowsRoot = "env:SystemDrive";
            const string linuxRoot = "env:HOME";

            var root = variables.Get(SpecialVariables.Tentacle.Agent.ApplicationDirectoryPath);
            if (root != null)
                return root;

            root = variables.Get(windowsRoot);
            if (root == null)
            {
                root = variables.Get(linuxRoot);
                if (root == null)
                {
                    throw new Exception(string.Format("Unable to determine the ApplicationRootDirectory. Please provide the {0} variable", SpecialVariables.Tentacle.Agent.ApplicationDirectoryPath));
                }
            }
            return string.Format("{0}{1}Applications", root, Path.DirectorySeparatorChar);
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:20,代码来源:ExtractPackageToApplicationDirectoryConvention.cs

示例9: ShouldSetVariables

        public void ShouldSetVariables()
        {
            var variables = new VariableDictionary();

            var output = Invoke(Calamari()
                .Action("run-script")
                .Argument("script", GetFixtureResouce("Scripts", "CanSetVariable.ps1")), variables);

            output.AssertZero();
            output.AssertOutput("##octopus[setVariable name='VGVzdEE=' value='V29ybGQh']");
            Assert.AreEqual("World!", variables.Get("TestA"));
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:12,代码来源:PowerShellFixture.cs

示例10: EnsureCertificateFileExists

        bool EnsureCertificateFileExists(string workingDirectory, VariableDictionary variables)
        {
            var certificateFilePath = Path.Combine(workingDirectory, certificateFileName);

            if (fileSystem.FileExists(certificateFileName))
                return true;

            var azureCertificate = certificateStore.GetOrAdd(
                variables.Get(SpecialVariables.Action.Azure.CertificateThumbprint),
                variables.Get(SpecialVariables.Action.Azure.CertificateBytes),
                StoreName.My);

            var certificatePassword = GenerateCertificatePassword();

            fileSystem.WriteAllBytes(certificateFilePath, azureCertificate.Export(X509ContentType.Pfx, certificatePassword));

            Log.SetOutputVariable(SpecialVariables.Action.Azure.Output.CertificateFileName, certificateFilePath, variables);
            Log.SetOutputVariable(SpecialVariables.Action.Azure.Output.CertificatePassword, certificatePassword, variables);

            return false;
        }
开发者ID:NoesisLabs,项目名称:Calamari,代码行数:21,代码来源:AzurePowershellContext.cs

示例11: Execute

        public CommandResult Execute(string scriptFile, VariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var scriptType = Path.GetExtension(scriptFile).TrimStart('.').ToScriptType();
            var engine = GetSpecificScriptEngine(scriptType);

            // When running Powershell against an Azure target, we load the Azure Powershell modules,
            // and set the Azure subscription
            if (scriptType == ScriptType.Powershell &&
                variables.Get(SpecialVariables.Account.AccountType) == "AzureSubscription")
            {
                var azureContextScriptFile = azurePowershellContext.CreateAzureContextScript(scriptFile, variables);
                return engine.Execute(azureContextScriptFile, variables, commandLineRunner);
            }

            return engine.Execute(scriptFile, variables, commandLineRunner);
        }
开发者ID:sergio,项目名称:Calamari,代码行数:16,代码来源:CombinedScriptEngine.cs

示例12: Generate

        public void Generate(string appSettingsFilePath, VariableDictionary variables)
        {
            var root = LoadJson(appSettingsFilePath);

            var names = variables.GetNames();
            names.Sort(StringComparer.OrdinalIgnoreCase);

            foreach (var name in names)
            {
                if (name.StartsWith("Octopus", StringComparison.OrdinalIgnoreCase))
                    continue;

                SetValueRecursive(root, name, name, variables.Get(name));
            }

            SaveJson(appSettingsFilePath, root);
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:17,代码来源:AppSettingsJsonGenerator.cs

示例13: GetEncoding

        private Encoding GetEncoding(string sourceFile, VariableDictionary variables)
        {
            var requestedEncoding = variables.Get(SpecialVariables.Package.SubstituteInFilesOutputEncoding);
            if (requestedEncoding == null)
            {
                return fileSystem.GetFileEncoding(sourceFile);
            }

            try
            {
                return Encoding.GetEncoding(requestedEncoding);
            }
            catch (ArgumentException)
            {
                return fileSystem.GetFileEncoding(sourceFile);
            }
        }
开发者ID:enlightendesigns,项目名称:Calamari,代码行数:17,代码来源:FileSubstituter.cs

示例14: WriteVariableDictionary

 static void WriteVariableDictionary(VariableDictionary variables, StringBuilder output)
 {
     output.AppendLine("$OctopusParameters = New-Object 'System.Collections.Generic.Dictionary[String,String]' (,[System.StringComparer]::OrdinalIgnoreCase)");
     foreach (var variableName in variables.GetNames().Where(name => !SpecialVariables.IsLibraryScriptModule(name)))
     {
         output.Append("$OctopusParameters[").Append(EncodeValue(variableName)).Append("] = ").AppendLine(EncodeValue(variables.Get(variableName)));
     }
 }
开发者ID:sergio,项目名称:Calamari,代码行数:8,代码来源:PowerShellBootstrapper.cs

示例15: WriteVariableDictionary

 static string WriteVariableDictionary(VariableDictionary variables)
 {
     var builder = new StringBuilder();
     foreach (var variable in variables.GetNames())
     {
         builder.AppendLine("    this[" + EncodeValue(variable) + "] = " + EncodeValue(variables.Get(variable)) + ";");
     }
     return builder.ToString();
 }
开发者ID:sergio,项目名称:Calamari,代码行数:9,代码来源:ScriptCSBootstrapper.cs


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