本文整理汇总了C#中Variables.ExpandValues方法的典型用法代码示例。如果您正苦于以下问题:C# Variables.ExpandValues方法的具体用法?C# Variables.ExpandValues怎么用?C# Variables.ExpandValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variables
的用法示例。
在下文中一共展示了Variables.ExpandValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandValues_HandlesNullValue
public void ExpandValues_HandlesNullValue()
{
using (TestHostContext hc = new TestHostContext(this))
{
// Arrange: Setup the variables.
List<string> warnings;
var variableDictionary = new Dictionary<string, string>
{
{ "variable1", "some variable 1 value " },
};
var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);
// Arrange: Setup the target dictionary.
var targetDictionary = new Dictionary<string, string>
{
{ "some target key", null },
};
// Act.
variables.ExpandValues(target: targetDictionary);
// Assert: The consecutive macros should both have been expanded.
Assert.Equal(string.Empty, targetDictionary["some target key"]);
}
}
示例2: ExpandValues_HandlesPreceedingPrefix
public void ExpandValues_HandlesPreceedingPrefix()
{
using (TestHostContext hc = new TestHostContext(this))
{
// Arrange: Setup the variables.
List<string> warnings;
var variableDictionary = new Dictionary<string, string>
{
{ "variable1", "some variable 1 value" },
};
var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);
// Arrange: Setup the target dictionary.
var targetDictionary = new Dictionary<string, string>();
targetDictionary["some target key"] = "before $($(variable1) after";
// Act.
variables.ExpandValues(target: targetDictionary);
// Assert: The consecutive macros should both have been expanded.
Assert.Equal("before $(some variable 1 value after", targetDictionary["some target key"]);
}
}
示例3: ExpandValues_DoesNotRecurse
public void ExpandValues_DoesNotRecurse()
{
using (TestHostContext hc = new TestHostContext(this))
{
// Arrange: Setup the variables. The value of the variable1 variable
// should not get expanded since variable2 does not exist when the
// variables class is initialized (and therefore would never get expanded).
List<string> warnings;
var variableDictionary = new Dictionary<string, string>
{
{ "variable1", "$(variable2)" },
};
var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);
variables.Set("variable2", "some variable 2 value");
// Arrange: Setup the target dictionary.
var targetDictionary = new Dictionary<string, string>();
targetDictionary["some target key"] = "before $(variable1) after";
// Act.
variables.ExpandValues(target: targetDictionary);
// Assert: The variable should only have been expanded one level.
Assert.Equal("before $(variable2) after", targetDictionary["some target key"]);
}
}