本文整理汇总了C#中RegexWizard.Framework.Scope.FindInnerScope方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.FindInnerScope方法的具体用法?C# Scope.FindInnerScope怎么用?C# Scope.FindInnerScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegexWizard.Framework.Scope
的用法示例。
在下文中一共展示了Scope.FindInnerScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSplitPoints
public List<SplitPoint> GetSplitPoints(Scope root, int newScopeStartIndex, int newScopeLength)
{
List<SplitPoint> splitPoints = new List<SplitPoint>();
if(root.IsFlat)
{
return splitPoints;
}
int requestedEndPos = newScopeStartIndex + newScopeLength - 1;
Scope innerLeft = root.FindInnerScope(newScopeStartIndex, 1);
Scope innerRight = root.FindInnerScope(requestedEndPos, 1);
bool isSpillingLeft = (innerLeft.StartPosInRootScope < newScopeStartIndex);
bool isSpillingRight = (innerRight.EndPosInRootScope > requestedEndPos);
if (isSpillingLeft)
{
int splitLength = (innerLeft.EndPosInRootScope-newScopeStartIndex)+1;
splitPoints.Add(new SplitPoint(newScopeStartIndex, splitLength));
}
if (isSpillingRight)
{
int splitLength = (requestedEndPos-innerRight.StartPosInRootScope)+1;
splitPoints.Add(new SplitPoint(innerRight.StartPosInRootScope, splitLength));
// splitPoints.Add(new SplitPoint(requestedEndPos, splitLength));
}
return splitPoints;
}
示例2: AutoScope
public void AutoScope(Scope root)
{
if(autoAdvisor==null)
{
return;
}
foreach (Suggestion possibility in autoAdvisor.possibleMatches)
{
Match match = Regex.Match(root.Text, possibility.RegexText);
if (match.Success)
{
Scope innerScope = root.FindInnerScope(match.Index, match.Length);
if (innerScope == null || innerScope.Length!=match.Length)
{
List<SplitPoint> points = new ScopeSplitter().GetSplitPoints(root, match.Index, match.Length);
bool willNewScopeBeInsdeAScopeWithSuggestions = false;
if (points.Count>0)
{
foreach (SplitPoint point in points)
{
Scope target = root.FindInnerScope(point.StartIndex, point.Length);
if(target!=null && target.Suggestions.Count>0)
{
willNewScopeBeInsdeAScopeWithSuggestions = true;
break;
}
}
}
if(!willNewScopeBeInsdeAScopeWithSuggestions)
innerScope = root.DefineInnerScope(match.Index, match.Length);
}
if (innerScope!=null)
{
innerScope.Suggestions.Add(possibility);
innerScope.IsExplicit = true;
}
}
}
}
示例3: GetInnerScope_NegativeStartPos_ThrowsException
public void GetInnerScope_NegativeStartPos_ThrowsException()
{
scope = new Scope("defge");//flat
scope.FindInnerScope(-1, 1);
}
示例4: GetInnerScope_MiddleIsNullByCharPos_GetsCorrectScope
public void GetInnerScope_MiddleIsNullByCharPos_GetsCorrectScope()
{
scope = new Scope("defge");
scope.DefineInnerScope(0, 2);//'de'
Assert.AreSame(scope.InnerLeftScope,
scope.FindInnerScope(1, 1));//g
}
示例5: GetInnerScope_IsFlat_ReturnsThis
public void GetInnerScope_IsFlat_ReturnsThis()
{
scope = new Scope("defge");//flat
Assert.AreSame(scope,
scope.FindInnerScope(2, 1));
}
示例6: GetInnerScope_InRightInnerScope_GetsCorrectScope
public void GetInnerScope_InRightInnerScope_GetsCorrectScope()
{
scope = new Scope("012345");
Scope inner = scope.DefineInnerScope(3, 3);//'345'
Scope deepInner = inner.DefineInnerScope(3, 1);//'3'
Assert.AreSame(deepInner,
scope.FindInnerScope(3, 1));//3
}
示例7: GetInnerScope_InMiddleInnerScope_GetsCorrectScope
public void GetInnerScope_InMiddleInnerScope_GetsCorrectScope()
{
scope = new Scope("abcde");
Scope inner = scope.DefineInnerScope(1, 3);//'bcd'
Scope deepInner = inner.DefineInnerScope(2, 1);//'c'
Assert.AreSame(deepInner,
scope.FindInnerScope(2, 1));//c
}
示例8: GetInnerScope_InLeftInnerScope_GetsCorrectScope
public void GetInnerScope_InLeftInnerScope_GetsCorrectScope()
{
scope = new Scope("012345");
Scope inner = scope.DefineInnerScope(0, 3);//'012'
Scope deepInner = inner.DefineInnerScope(2, 1);//'2'
Assert.AreSame(deepInner,
scope.FindInnerScope(2, 1));//2
}
示例9: Split
public Scope Split(Scope root, SplitPoint splitPoint, bool isImplicit)
{
Scope inner = root.FindInnerScope(splitPoint.StartIndex, 1);
int requiredLength = splitPoint.Length;
if(requiredLength==inner.Length)
{
requiredLength -= 1;
}
Scope newScope = inner.DefineInnerScope(splitPoint.StartIndex, requiredLength);
newScope.IsImplicit= isImplicit;
return newScope;
}
示例10: GetInnerScope_ForWholeRootScope_ReturnsRoot
public void GetInnerScope_ForWholeRootScope_ReturnsRoot()
{
scope = new Scope("defge");
Assert.AreSame(scope,
scope.FindInnerScope(0, scope.Length));
}
示例11: GetInnerScope_ByCharPos_GetsCorrectScope6
public void GetInnerScope_ByCharPos_GetsCorrectScope6()
{
scope = new Scope("defge");
scope.DefineInnerScope(2, 2);//'fg'
Assert.AreSame(scope.InnerMiddleScope,
scope.FindInnerScope(3, 1));//g
}
示例12: GetInnerScope_ByCharPos_GetsCorrectScope5
public void GetInnerScope_ByCharPos_GetsCorrectScope5()
{
scope = new Scope("defge");
scope.DefineInnerScope(1, 1);//'e'
Scope found = scope.FindInnerScope(4, 1);//'fge'
Assert.AreSame(scope.InnerRightScope, found);//e
}
示例13: GetInnerScope_ByCharPos_GetsCorrectScope2
public void GetInnerScope_ByCharPos_GetsCorrectScope2()
{
scope = new Scope("defge");
scope.DefineInnerScope(2, 2);//'fg'
Assert.AreSame(scope.InnerRightScope,
scope.FindInnerScope(4, 1));//e
}
示例14: IsMultipleSplittingNeededFor
public bool IsMultipleSplittingNeededFor(Scope root, int newScopeStartIndex, int newScopeLength)
{
int requestedEndPos = newScopeStartIndex + newScopeLength - 1;
Scope innerLeft = root.FindInnerScope(newScopeStartIndex, 1);
Scope innerRight = root.FindInnerScope(requestedEndPos, 1);
bool isSpillingLeft = (innerLeft.StartPosInRootScope < newScopeStartIndex);
bool isSpillingRight = (innerRight.EndPosInRootScope > requestedEndPos);
return (isSpillingRight && isSpillingLeft);
}
示例15: GetInnerScope_overflowingLengthFromMiddle_THrowsException
public void GetInnerScope_overflowingLengthFromMiddle_THrowsException()
{
scope = new Scope("defge");//flat
scope.FindInnerScope(3, 3);//one char overflow
}