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


C# ConfigNode.ToDictionary方法代码示例

本文整理汇总了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);
        }
开发者ID:killthrush,项目名称:Habitat.Core,代码行数:47,代码来源:ConfigDtoTests.cs

示例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);
        }
开发者ID:killthrush,项目名称:Habitat.Core,代码行数:19,代码来源:ConfigDtoTests.cs

示例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();
 }
开发者ID:killthrush,项目名称:Habitat.Core,代码行数:15,代码来源:ConfigDtoTests.cs

示例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);
        }
开发者ID:killthrush,项目名称:Habitat.Core,代码行数:20,代码来源:ConfigDtoTests.cs

示例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);
        }
开发者ID:killthrush,项目名称:Habitat.Core,代码行数:20,代码来源:ConfigDtoTests.cs


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