本文整理汇总了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);
}
示例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);
}
示例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]);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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]);
}