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


C# VariableDictionary.GetNames方法代码示例

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


在下文中一共展示了VariableDictionary.GetNames方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

示例4: ApplyChanges

        static List<string> ApplyChanges(XNode doc, VariableDictionary variables)
        {
            var changes = new List<string>();

            foreach (var variable in variables.GetNames())
            {
                changes.AddRange(
                    ReplaceAppSettingOrConnectionString(doc, "//*[local-name()='appSettings']/*[local-name()='add']", "key", variable, "value", variables).Concat(
                    ReplaceAppSettingOrConnectionString(doc, "//*[local-name()='connectionStrings']/*[local-name()='add']", "name", variable, "connectionString", variables).Concat(
                    ReplaceStonglyTypeApplicationSetting(doc, "//*[local-name()='applicationSettings']//*[local-name()='setting']", "name", variable, variables))));
            }
            return changes;
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:13,代码来源:ConfigurationVariablesReplacer.cs

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

示例6: ModifyConfigurationFile

        public void ModifyConfigurationFile(string configurationFilePath, VariableDictionary variables)
        {
            XDocument doc;

            using (var reader = XmlReader.Create(configurationFilePath, XmlUtils.DtdSafeReaderSettings))
            {
                doc = XDocument.Load(reader, LoadOptions.PreserveWhitespace);
            }

            var changes = new List<string>();

            foreach (var variable in variables.GetNames())
            {
                changes.AddRange(
                    ReplaceAppSettingOrConnectionString(doc, "//*[local-name()='appSettings']/*[local-name()='add']", "key", variable, "value", variables).Concat(
                    ReplaceAppSettingOrConnectionString(doc, "//*[local-name()='connectionStrings']/*[local-name()='add']", "name", variable, "connectionString", variables).Concat(
                    ReplaceStonglyTypeApplicationSetting(doc, "//*[local-name()='applicationSettings']//*[local-name()='setting']", "name", variable, variables))));
            }

            if (!changes.Any())
            {
                Log.Info("No matching setting or connection string names were found in: {0}", configurationFilePath);
                return;
            }

            Log.Info("Updating appSettings and connectionStrings in: {0}", configurationFilePath);

            foreach (var change in changes)
            {
                Log.Verbose(change);
            }

            var xws = new XmlWriterSettings { OmitXmlDeclaration = doc.Declaration == null, Indent = true };
            using (var writer = XmlWriter.Create(configurationFilePath, xws))
            {
                doc.Save(writer);
            }
        }
开发者ID:merbla,项目名称:Calamari,代码行数:38,代码来源:ConfigurationVariablesReplacer.cs

示例7: MergeWith

 public static void MergeWith(this VariableDictionary variables, VariableDictionary other)
 {
     other.GetNames().ForEach(name => variables.Set(name, other.GetRaw(name)));
 }
开发者ID:allansson,项目名称:Calamari,代码行数:4,代码来源:VariableDictionaryExtensions.cs

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

示例9: WriteScriptModules

 static void WriteScriptModules(VariableDictionary variables, StringBuilder output)
 {
     foreach (var variableName in variables.GetNames().Where(SpecialVariables.IsLibraryScriptModule))
     {
         var name = "Library_" + new string(SpecialVariables.GetLibraryScriptModuleName(variableName).Where(char.IsLetterOrDigit).ToArray()) + "_" + DateTime.Now.Ticks;
         output.Append("New-Module -Name ").Append(name).Append(" -ScriptBlock {");
         output.AppendLine(variables.Get(variableName));
         output.AppendLine("} | Import-Module");
         output.AppendLine();
     }
 }
开发者ID:sergio,项目名称:Calamari,代码行数:11,代码来源:PowerShellBootstrapper.cs

示例10: WriteLocalVariables

        static void WriteLocalVariables(VariableDictionary variables, StringBuilder output)
        {
            foreach (var variableName in variables.GetNames().Where(name => !SpecialVariables.IsLibraryScriptModule(name)))
            {
                if (SpecialVariables.IsExcludedFromLocalVariables(variableName))
                {
                    continue;
                }

                // This is the way we used to fix up the identifiers - people might still rely on this behavior
                var legacyKey = new string(variableName.Where(char.IsLetterOrDigit).ToArray());

                // This is the way we should have done it
                var smartKey = new string(variableName.Where(IsValidPowerShellIdentifierChar).ToArray());

                if (legacyKey != smartKey)
                {
                    WriteVariableAssignment(output, legacyKey, variableName);
                }

                WriteVariableAssignment(output, smartKey, variableName);
            }
        }
开发者ID:sergio,项目名称:Calamari,代码行数:23,代码来源:PowerShellBootstrapper.cs

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

示例12: GetVariableSwitchConditions

 static IEnumerable<string> GetVariableSwitchConditions(VariableDictionary variables)
 {
     return variables.GetNames().Select(variable => string.Format("    \"{1}\"){0}    decode_servicemessagevalue \"{2}\"  ;;{0}", Environment.NewLine, EncodeValue(variable), EncodeValue(variables.Get(variable))));
 }
开发者ID:sergio,项目名称:Calamari,代码行数:4,代码来源:BashScriptBootstrapper.cs


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