本文整理汇总了C#中System.ConfigNode.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.ToDictionary方法的具体用法?C# ConfigNode.ToDictionary怎么用?C# ConfigNode.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.ToDictionary方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert_root_to_dictionary_when_there_is_a_complex_object_graph
public void Convert_root_to_dictionary_when_there_is_a_complex_object_graph()
{
var originalNode = new ConfigNode();
originalNode.Name = "N1";
originalNode.Children = new List<ConfigNode>
{
CreateValueNode(1),
CreateValueNode(2),
new ConfigNode
{
Name = "N2",
Children = new List<ConfigNode>
{
CreateValueNode(5),
}
},
CreateValueNode(3),
CreateValueNode(4),
new ConfigNode
{
Name = "N3",
Children = new List<ConfigNode>
{
CreateValueNode(6),
new ConfigNode
{
Name = "N6",
Children = new List<ConfigNode>
{
CreateValueNode(8),
}
}
}
}
};
var expectedDictionary = new Dictionary<string, string>();
expectedDictionary["N1.N1"] = "V1";
expectedDictionary["N1.N2"] = "V2";
expectedDictionary["N1.N2.N5"] = "V5";
expectedDictionary["N1.N3"] = "V3";
expectedDictionary["N1.N4"] = "V4";
expectedDictionary["N1.N3.N6"] = "V6";
expectedDictionary["N1.N3.N6.N8"] = "V8";
Assert.IsTrue(_objectComparer.Compare(expectedDictionary, originalNode.ToDictionary()).AreEqual);
}
示例2: Convert_root_to_dictionary_when_there_is_leading_or_trailing_whitespace_in_the_contents
public void Convert_root_to_dictionary_when_there_is_leading_or_trailing_whitespace_in_the_contents()
{
var node = new ConfigNode();
node.Children = new List<ConfigNode>
{
CreateValueNodeWithWhitespace(1),
CreateValueNodeWithWhitespace(2),
CreateValueNodeWithWhitespace(3),
CreateValueNodeWithWhitespace(4)
};
var expectedDictionary = new Dictionary<string, string>();
expectedDictionary[".N1"] = "V1";
expectedDictionary[".N2"] = "V2";
expectedDictionary[".N3"] = "V3";
expectedDictionary[".N4"] = "V4";
Assert.IsTrue(_objectComparer.Compare(expectedDictionary, node.ToDictionary()).AreEqual);
}
示例3: Convert_root_to_dictionary_when_there_are_duplicate_names
public void Convert_root_to_dictionary_when_there_are_duplicate_names()
{
var node = new ConfigNode();
node.Name = "N1";
node.Children = new List<ConfigNode>
{
CreateValueNode(1),
CreateValueNode(2),
CreateValueNode(3),
CreateValueNode(4)
};
node.Children[1].Name = "foo";
node.Children[2].Name = "foo";
node.ToDictionary();
}
示例4: Convert_root_to_dictionary_when_there_are_nulls_in_some_of_the_names
public void Convert_root_to_dictionary_when_there_are_nulls_in_some_of_the_names()
{
var node = new ConfigNode();
node.Children = new List<ConfigNode>
{
CreateValueNode(1),
CreateValueNode(2),
CreateValueNode(3),
CreateValueNode(4)
};
node.Children[1].Name = null; // Nulls alone should not cause this to break
var expectedDictionary = new Dictionary<string, string>();
expectedDictionary[".N1"] = "V1";
expectedDictionary["."] = "V2";
expectedDictionary[".N3"] = "V3";
expectedDictionary[".N4"] = "V4";
Assert.IsTrue(_objectComparer.Compare(expectedDictionary, node.ToDictionary()).AreEqual);
}
示例5: Convert_root_to_dictionary_when_there_are_no_duplicate_names
public void Convert_root_to_dictionary_when_there_are_no_duplicate_names()
{
var node = new ConfigNode();
node.Name = "N1";
node.Children = new List<ConfigNode>
{
CreateValueNode(1),
CreateValueNode(2),
CreateValueNode(3),
CreateValueNode(4)
};
var expectedDictionary = new Dictionary<string, string>();
expectedDictionary["N1.N1"] = "V1";
expectedDictionary["N1.N2"] = "V2";
expectedDictionary["N1.N3"] = "V3";
expectedDictionary["N1.N4"] = "V4";
Assert.IsTrue(_objectComparer.Compare(expectedDictionary, node.ToDictionary()).AreEqual);
}