static IEnumerable<string> GetVariableSwitchConditions(CalamariVariableDictionary variables) { return variables.GetNames().Select(variable => { var variableValue = variables.IsSensitive(variable) ? DecryptValueCommand(variables.Get(variable)) : string.Format("decode_servicemessagevalue \"{0}\"", EncodeValue(variables.Get(variable))); return string.Format(" \"{1}\"){0} {2} ;;{0}", Environment.NewLine, EncodeValue(variable), variableValue); }); }
static void WriteVariableDictionary(CalamariVariableDictionary 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))) { var variableValue = variables.IsSensitive(variableName) ? EncryptVariable(variables.Get(variableName)) : EncodeValue(variables.Get(variableName)); output.Append("$OctopusParameters[").Append(EncodeValue(variableName)).Append("] = ").AppendLine(variableValue); } }
static string WriteVariableDictionary(CalamariVariableDictionary variables) { var builder = new StringBuilder(); foreach (var variable in variables.GetNames()) { var variableValue = variables.IsSensitive(variable) ? EncryptVariable(variables.Get(variable)) : EncodeValue(variables.Get(variable)); builder.Append("\t\t\tthis[").Append(EncodeValue(variable)).Append("] = ").Append(variableValue).AppendLine(";"); } return builder.ToString(); }