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


C# Scope.DefineInnerScope方法代码示例

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


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

示例1: DefineInnerScope_WithEncapsulator_ClearsOlderSuggestionsForRightInner

        public void DefineInnerScope_WithEncapsulator_ClearsOlderSuggestionsForRightInner()
        {
            Scope root = new Scope("012");
            root.DefineInnerScope(0, 1);
            root.DefineInnerScope(1, 1);
            suggest.Suggest(root);
            Scope encapsulator = root.DefineInnerScope(0, 2);

            List<Suggestion> list = suggest.Suggest(root);
            Assert.AreEqual("^0$^1$^2$", list[0].RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:RegexAdvisorTests.cs

示例2: NonFlatScope

        public void NonFlatScope()
        {
            string filename = TEST_FILE_NAME;
            Scope s = new  Scope("abc");
            s.DefineInnerScope(1, 1);
            s.Save<Scope>(filename);

            Scope loaded = Scope.Load<Scope>(filename);
            Assert.AreEqual(3,loaded.GetInnerScopes().Length);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:10,代码来源:ScopeSerializerTests.cs

示例3: SimpleScopeWith1SuggestionInInner

        public void SimpleScopeWith1SuggestionInInner()
        {
            string filename = TEST_FILE_NAME;
            Scope s = new Scope("abc");
            Suggestion sug = new Suggestion("a","b");
            s.DefineInnerScope(1,1).Suggestions.Add(sug);
            s.Save<Scope>(filename);

            Scope loaded = Scope.Load<Scope>(filename);
            Assert.AreEqual(sug, loaded.InnerMiddleScope.Suggestions[0]);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:ScopeSerializerTests.cs

示例4: NonFlatScope2LevelsDeep

        public void NonFlatScope2LevelsDeep()
        {
            string filename = TEST_FILE_NAME;
            Scope s = new  Scope("abcd");
            s.DefineInnerScope(1, 2).DefineInnerScope(2,1);
            s.Save<Scope>(filename);

            Scope loaded = Scope.Load<Scope>(filename);
            Assert.IsNotNull(loaded.InnerMiddleScope.InnerLeftScope);
            Assert.IsNotNull(loaded.InnerMiddleScope.InnerRightScope);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:ScopeSerializerTests.cs

示例5: Sugggest_NamedScopeWithInnerScopes_ReturnesCombinedInsideGroup

 public void Sugggest_NamedScopeWithInnerScopes_ReturnesCombinedInsideGroup()
 {
     Scope root = new Scope("abc","RootName");
     root.DefineInnerScope(1, 1);
     Suggestion suggestion = suggest.Suggest(root)[0];
     Assert.AreEqual(@"(?<RootName>^a$^b$^c$)",suggestion.RegexText);
 }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:7,代码来源:RegexAdvisorTests.cs

示例6: Sugggest_NamedScopeWithInnerNamedScopesAndMultipleSuggestions_ReturnesCombinedInsideGroup

        public void Sugggest_NamedScopeWithInnerNamedScopesAndMultipleSuggestions_ReturnesCombinedInsideGroup()
        {
            //More than one alternative for the named Scopes besides the default one
            suggest.Learn(new Suggestion(@".", "anything"));

            Scope root = new Scope("abc", "RootName");
            Scope inner = root.DefineInnerScope(1, 1);
            inner.Name="Inner";
            Suggestion suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"(?<RootName>^a$(?<Inner>^b$)^c$)",suggestion.RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:RegexAdvisorTests.cs

示例7: Sugggest_InnerNamedScopesWithUnNamedRoot_ReturnesCombinedInsideGroup

 public void Sugggest_InnerNamedScopesWithUnNamedRoot_ReturnesCombinedInsideGroup()
 {
     suggest.UseGroupsForUnnamedScopes = true;
     Scope root = new Scope("abc");
     Scope inner = root.DefineInnerScope(1, 1);
     inner.Name="Inner";
     Suggestion suggestion = suggest.Suggest(root)[0];
     Assert.AreEqual(@"((^a$)(?<Inner>^b$)(^c$))",suggestion.RegexText);
 }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:9,代码来源:RegexAdvisorTests.cs

示例8: UseGroupsForUnNamedScopes_UnNamedScopeWithInnerScopes_ReturnesCombinedInsideGroup

 public void UseGroupsForUnNamedScopes_UnNamedScopeWithInnerScopes_ReturnesCombinedInsideGroup()
 {
     Scope root = new Scope("abc");
     root.DefineInnerScope(1, 1);
     suggest.UseGroupsForUnnamedScopes = true;
     Suggestion suggestion = suggest.Suggest(root)[0];
     Assert.AreEqual(@"((^a$)(^b$)(^c$))",suggestion.RegexText);
 }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:8,代码来源:RegexAdvisorTests.cs

示例9: UseGroupsForUnNamedScopes_LeftiNnerNameUsed

        public void UseGroupsForUnNamedScopes_LeftiNnerNameUsed()
        {
            Scope root = new Scope("abc");
            root.DefineInnerScope(1, 1);

            suggest.UseGroupsForUnnamedScopes = true;
            Suggestion suggestion = suggest.Suggest(root)[0];

            root.InnerLeftScope.Name = "left";
            root.InnerLeftScope.Suggestions.Add(new Suggestion(".","anything"));
            Suggestion newsuggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"((?<left>.)(^b$)(^c$))", newsuggestion.RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:13,代码来源:RegexAdvisorTests.cs

示例10: Sugggest_UnNamedScopeWithIneRecentlyNamedInnerScope2ndSuggestion_ReturnesCombinedCintainingGroup

        public void Sugggest_UnNamedScopeWithIneRecentlyNamedInnerScope2ndSuggestion_ReturnesCombinedCintainingGroup()
        {
            Scope root = new Scope("abc");
            root.DefineInnerScope(1, 1);
            suggest.Suggest(root);

            root.InnerLeftScope.Name = "first";
            Suggestion suggestion = suggest.Suggest(root)[0];
            Assert.AreEqual(@"(?<first>^a$)^b$^c$",suggestion.RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:10,代码来源:RegexAdvisorTests.cs

示例11: Suggest_NonFlatScopeWithInnerAndOwnPrototype_IgnoresOwnPrototype

        public void Suggest_NonFlatScopeWithInnerAndOwnPrototype_IgnoresOwnPrototype()
        {
            Suggestion protoype = new Suggestion("proto", "prototype", "single");
            Scope root = new Scope("abc");
            suggest.Learn(protoype);
            root.Prototype = "single";
            root.DefineInnerScope(1, 1);
            root.InnerLeftScope.Suggestions.Add(new Suggestion("X", "anything"));
            root.InnerMiddleScope.Suggestions.Add(new Suggestion("Y", "anything"));
            root.InnerRightScope.Suggestions.Add(new Suggestion("Z", "anything"));

            List<Suggestion> list = suggest.Suggest(root);
            Assert.AreEqual("XYZ", list[0].RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:14,代码来源:RegexAdvisorTests.cs

示例12: Suggest_NonFlatScopeWithEmptySuggestions_SuggestsAllHierarchyNonDefault

        public void Suggest_NonFlatScopeWithEmptySuggestions_SuggestsAllHierarchyNonDefault()
        {
            Suggestion sug = new Suggestion(".", "anything");
            suggest.Learn(sug);
            Scope root = new Scope("abc");

            root.DefineInnerScope(1, 1);

            List<Suggestion> list = suggest.Suggest(root);
            Assert.AreEqual("...", list[1].RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:RegexAdvisorTests.cs

示例13: Suggest_NonFlatScopeWithEmptySuggestions_SuggestsAllHierarchyDefault

        public void Suggest_NonFlatScopeWithEmptySuggestions_SuggestsAllHierarchyDefault()
        {
            Scope root = new Scope("abc");
            root.DefineInnerScope(1, 1);

            List<Suggestion> list = suggest.Suggest(root);
            Assert.AreEqual("^a$^b$^c$", list[0].RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:8,代码来源:RegexAdvisorTests.cs

示例14: Suggest_EncapsulatingScope2mostRightInnerScopes_WorksOK_Right

        public void Suggest_EncapsulatingScope2mostRightInnerScopes_WorksOK_Right()
        {
            Scope root = new     Scope("012");
            root.DefineInnerScope(0, 1);
            root.DefineInnerScope(1, 1);
            Scope encapsulator = root.DefineInnerScope(0, 2);

            List<Suggestion> list = suggest.Suggest(root);
            Assert.AreEqual("^0$^1$^2$", list[0].RegexText);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:10,代码来源:RegexAdvisorTests.cs

示例15: Suggest_CombinedScopes_SuggestsExactWhenPossible

        public void Suggest_CombinedScopes_SuggestsExactWhenPossible()
        {
            RegexAdvisor s = new RegexAdvisor();
            s.Learn(new Suggestion(@"\w", "any letter or num", 100));

            Scope scope = new Scope("abc");
            scope.DefineInnerScope(1, 1);

            List<Suggestion> suggestions = s.Suggest(scope);
            Assert.AreEqual(new Suggestion("^a$^b$^c$", "Combined"), suggestions[0]);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:RegexAdvisorTests.cs


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