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


C# Block.LocateOwner方法代码示例

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


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

示例1: LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan

        public void LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan() {
            // Arrange
            Block block = new Block(BlockType.Markup, new SyntaxTreeNode[] {
                new MarkupSpan(SourceLocation.Zero, "Foo "),
                new StatementBlock(new SyntaxTreeNode[] {
                    new TransitionSpan(new SourceLocation(4, 0, 4), "@"),
                    new CodeSpan(new SourceLocation(5, 0, 5), "bar"),
                }),
                new MarkupSpan(new SourceLocation(8,0,8), " Baz")
            });
            TextChange change = new TextChange(128, 1, new StringTextBuffer("Foo @bar Baz"), 1, new StringTextBuffer("Foo @bor Baz"));

            // Act
            Span actual = block.LocateOwner(change);

            // Assert
            Assert.IsNull(actual);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:18,代码来源:BlockTest.cs

示例2: TreesAreDifferent

        internal static bool TreesAreDifferent(Block leftTree, Block rightTree, IEnumerable<TextChange> changes, CancellationToken cancelToken)
        {
            // Apply all the pending changes to the original tree
            // PERF: If this becomes a bottleneck, we can probably do it the other way around,
            //  i.e. visit the tree and find applicable changes for each node.
            foreach (TextChange change in changes)
            {
                cancelToken.ThrowIfCancellationRequested();
                Span changeOwner = leftTree.LocateOwner(change);

                // Apply the change to the tree
                if (changeOwner == null)
                {
                    return true;
                }
                EditResult result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true);
                changeOwner.ReplaceWith(result.EditedSpan);
            }

            // Now compare the trees
            bool treesDifferent = !leftTree.EquivalentTo(rightTree);
            return treesDifferent;
        }
开发者ID:strawd,项目名称:aspnetwebstack,代码行数:23,代码来源:BackgroundParser.cs

示例3: TreesAreDifferent

        internal static bool TreesAreDifferent(Block leftTree, Block rightTree, TextChange[] changes)
        {
            // Apply all the pending changes to the original tree
            // PERF: If this becomes a bottleneck, we can probably do it the other way around,
            //  i.e. visit the tree and find applicable changes for each node.
            foreach (TextChange change in changes)
            {
                Span changeOwner = leftTree.LocateOwner(change);

                // Apply the change to the tree
                if (changeOwner == null)
                {
                    return true;
                }
                EditResult result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true);
                changeOwner.ReplaceWith(result.EditedSpan);
            }

            // Now compare the trees
            bool treesDifferent = !leftTree.EquivalentTo(rightTree);
#if DEBUG
            if (RazorDebugHelpers.OutputDebuggingEnabled)
            {
                Debug.WriteLine(String.Format(CultureInfo.CurrentCulture, "Processed {0} changes, trees were{1} different", changes.Length, treesDifferent ? String.Empty : " not"));
            }
#endif
            return treesDifferent;
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:28,代码来源:RazorEditorParser.cs

示例4: TreesAreDifferent

        private static bool TreesAreDifferent(Block leftTree, Block rightTree, TextChange change) {
            Span changeOwner = leftTree.LocateOwner(change);

            // Apply the change to the tree
            if (changeOwner == null) {
                return true;
            }
            changeOwner.ApplyChange(change, force: true);

            // Now compare the trees
            return !Equals(leftTree, rightTree);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:12,代码来源:RazorEditorParser.cs


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