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


C# Scope.FindInnerScope方法代码示例

本文整理汇总了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;
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:27,代码来源:ScopeSPlitter.cs

示例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;
                    }
                }
            }
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:41,代码来源:RegexAdvisor.cs

示例3: GetInnerScope_NegativeStartPos_ThrowsException

 public void GetInnerScope_NegativeStartPos_ThrowsException()
 {
     scope = new Scope("defge");//flat
     scope.FindInnerScope(-1, 1);
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:5,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:7,代码来源:ScopeTests.cs

示例5: GetInnerScope_IsFlat_ReturnsThis

 public void GetInnerScope_IsFlat_ReturnsThis()
 {
     scope = new Scope("defge");//flat
     Assert.AreSame(scope,
         scope.FindInnerScope(2, 1));
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:6,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:8,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:8,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:8,代码来源:ScopeTests.cs

示例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;
 }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:12,代码来源:ScopeSPlitter.cs

示例10: GetInnerScope_ForWholeRootScope_ReturnsRoot

 public void GetInnerScope_ForWholeRootScope_ReturnsRoot()
 {
     scope = new Scope("defge");
     Assert.AreSame(scope,
         scope.FindInnerScope(0, scope.Length));
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:6,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:7,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:7,代码来源:ScopeTests.cs

示例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
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:7,代码来源:ScopeTests.cs

示例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);
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:11,代码来源:ScopeSPlitter.cs

示例15: GetInnerScope_overflowingLengthFromMiddle_THrowsException

 public void GetInnerScope_overflowingLengthFromMiddle_THrowsException()
 {
     scope = new Scope("defge");//flat
     scope.FindInnerScope(3, 3);//one char overflow
 }
开发者ID:FelicePollano,项目名称:dotnet-regex-tools,代码行数:5,代码来源:ScopeTests.cs


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