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


C# Trie.Merge方法代码示例

本文整理汇总了C#中Trie.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# Trie.Merge方法的具体用法?C# Trie.Merge怎么用?C# Trie.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trie的用法示例。


在下文中一共展示了Trie.Merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestTrieMerge

        public void TestTrieMerge()
        {
            var endPointDescriptor = new TestEndPointDescriptor {
                Name = "foo",
            };

            var firstTrie = new Trie();
            firstTrie.Insert("firstSegment/secondSegment", null);
            var secondTrie = new Trie();

            var path = "firstSegment/anotherSegment";

            secondTrie.Insert(path,  endPointDescriptor);

            firstTrie.Merge(secondTrie, path);

            var uri = new Uri("http://localhost:8081/firstSegment/anotherSegment");

            Regex rgx;

            var endPoint = firstTrie.ResolveRequest(uri, out rgx);
            Assert.AreEqual("foo", endPoint.Name);
        }
开发者ID:scoutmedia,项目名称:Sid,代码行数:23,代码来源:TrieTests.cs

示例2: TestStaticEndPointAfterTokenizedEndPoint

        public void TestStaticEndPointAfterTokenizedEndPoint()
        {
            var endPointDescriptor = new TestEndPointDescriptor {
                Name = "foo",
            };

            var firstTrie = new Trie();
            firstTrie.Insert("content/media/{id}", endPointDescriptor);
            var secondTrie = new Trie();

            var path = "content/media/search";

            secondTrie.Insert(path,  null);

            firstTrie.Merge(secondTrie, path);

            var uri = new Uri("http://localhost:8081/content/media/12345");

            Regex rgx;

            var endPoint = firstTrie.ResolveRequest(uri, out rgx);
            Assert.AreEqual("foo", endPoint.Name);
        }
开发者ID:scoutmedia,项目名称:Sid,代码行数:23,代码来源:TrieTests.cs

示例3: TestTrieMergeSegAfterToken

        public void TestTrieMergeSegAfterToken()
        {
            var endPointDescriptor1 = new TestEndPointDescriptor {
                Name = "foo",
            };
            var endPointDescriptor2 = new TestEndPointDescriptor {
                Name = "bar",
            };

            Regex rgx;
            var path = "content/sites/{siteId}/settings";
            var uri1 = new Uri("http://localhost:8081/content/sites/2343");
            var uri2 = new Uri("http://localhost:8081/content/sites/2343/settings");

            var insertTrie = new Trie();
            insertTrie.Insert("content/sites/{id}", endPointDescriptor1);
            insertTrie.Insert(path, endPointDescriptor2);

            var endPointPre = insertTrie.ResolveRequest(uri1, out rgx);
            Assert.AreEqual("foo", endPointPre.Name);

            endPointPre = insertTrie.ResolveRequest(uri2, out rgx);
            Assert.AreEqual("bar", endPointPre.Name);

            var mergeTrie = new Trie();
            mergeTrie.Insert("content/sites/{id}", endPointDescriptor1);

            var singleEndPointTrie = new Trie();
            singleEndPointTrie.Insert(path,  endPointDescriptor2);

            mergeTrie.Merge(singleEndPointTrie, path);

            var endPoint = mergeTrie.ResolveRequest(uri1, out rgx);
            Assert.AreEqual("foo", endPoint.Name);

            endPoint = mergeTrie.ResolveRequest(uri2, out rgx);
            Assert.AreEqual("bar", endPoint.Name);
        }
开发者ID:scoutmedia,项目名称:Sid,代码行数:38,代码来源:TrieTests.cs

示例4: TestTrieMergeSecondWithNoToken

        public void TestTrieMergeSecondWithNoToken()
        {
            var endPointDescriptor = new TestEndPointDescriptor {
                Name = "foo",
            };

            Regex rgx;
            var path = "content/sites";
            var uri = new Uri("http://localhost:8081/content/sites");

            var firstTrie = new Trie();
            firstTrie.Insert("content/sites/{siteId}", null);
            var secondTrie = new Trie();
            secondTrie.Insert(path,  endPointDescriptor);
            firstTrie.Merge(secondTrie, path);

            var endPoint = firstTrie.ResolveRequest(uri, out rgx);
            Assert.AreEqual("foo", endPoint.Name);
        }
开发者ID:scoutmedia,项目名称:Sid,代码行数:19,代码来源:TrieTests.cs


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