本文整理匯總了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);
}