• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Text.TextChange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.Razor.Text.TextChange的典型用法代码示例。如果您正苦于以下问题:C# TextChange类的具体用法?C# TextChange怎么用?C# TextChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextChange类属于System.Web.Razor.Text命名空间,在下文中一共展示了TextChange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteDebugTree

        internal static void WriteDebugTree(string sourceFile, Block document, PartialParseResult result, TextChange change, RazorEditorParser parser, bool treeStructureChanged)
        {
            if (!OutputDebuggingEnabled)
            {
                return;
            }

            RunTask(() =>
            {
                string outputFileName = Normalize(sourceFile) + "_tree";
                string outputPath = Path.Combine(Path.GetDirectoryName(sourceFile), outputFileName);

                var treeBuilder = new StringBuilder();
                WriteTree(document, treeBuilder);
                treeBuilder.AppendLine();
                treeBuilder.AppendFormat(CultureInfo.CurrentCulture, "Last Change: {0}", change);
                treeBuilder.AppendLine();
                treeBuilder.AppendFormat(CultureInfo.CurrentCulture, "Normalized To: {0}", change.Normalize());
                treeBuilder.AppendLine();
                treeBuilder.AppendFormat(CultureInfo.CurrentCulture, "Partial Parse Result: {0}", result);
                treeBuilder.AppendLine();
                if (result.HasFlag(PartialParseResult.Rejected))
                {
                    treeBuilder.AppendFormat(CultureInfo.CurrentCulture, "Tree Structure Changed: {0}", treeStructureChanged);
                    treeBuilder.AppendLine();
                }
                if (result.HasFlag(PartialParseResult.AutoCompleteBlock))
                {
                    treeBuilder.AppendFormat(CultureInfo.CurrentCulture, "Auto Complete Insert String: \"{0}\"", parser.GetAutoCompleteString());
                    treeBuilder.AppendLine();
                }
                File.WriteAllText(outputPath, treeBuilder.ToString());
            });
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:34,代码来源:RazorDebugHelpers.cs


示例2: BackgroundParseTask

 private BackgroundParseTask(RazorTemplateEngine engine, string sourceFileName, TextChange change)
 {
     Change = change;
     Engine = engine;
     SourceFileName = sourceFileName;
     InnerTask = new Task(() => Run(_cancelSource.Token), _cancelSource.Token);
 }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:7,代码来源:BackgroundParseTask.cs


示例3: CheckForStructureChangesStartsFullReparseIfChangeOverlapsMultipleSpans

        public void CheckForStructureChangesStartsFullReparseIfChangeOverlapsMultipleSpans() {
            // Arrange
            RazorEditorParser parser = new RazorEditorParser(CreateHost(), TestLinePragmaFileName);
            ITextBuffer original = new StringTextBuffer("Foo @bar Baz");
            ITextBuffer changed = new StringTextBuffer("Foo @bap Daz");
            TextChange change = new TextChange(7, 3, original, 3, changed);

            ManualResetEventSlim parseComplete = new ManualResetEventSlim();
            int parseCount = 0;
            parser.DocumentParseComplete += (sender, args) => {
                Interlocked.Increment(ref parseCount);
                parseComplete.Set();
            };

            Assert.AreEqual(PartialParseResult.Rejected, parser.CheckForStructureChanges(new TextChange(0, 0, new StringTextBuffer(String.Empty), 12, original)));
            MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait); // Wait for the parse to finish
            parseComplete.Reset();

            // Act
            PartialParseResult result = parser.CheckForStructureChanges(change);
            
            // Assert
            Assert.AreEqual(PartialParseResult.Rejected, result);
            MiscUtils.DoWithTimeoutIfNotDebugging(parseComplete.Wait);
            Assert.AreEqual(2, parseCount);
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:26,代码来源:RazorEditorParserTest.cs


示例4: OwnsChange

 public virtual bool OwnsChange(Span target, TextChange change)
 {
     int end = target.Start.AbsoluteIndex + target.Length;
     int changeOldEnd = change.OldPosition + change.OldLength;
     return change.OldPosition >= target.Start.AbsoluteIndex &&
            (changeOldEnd < end || (changeOldEnd == end && AcceptedCharacters != AcceptedCharacters.None));
 }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:7,代码来源:SpanEditHandler.cs


示例5: OwnsChangeReturnsFalseIfChangeIsReplacementOrDeleteAtSpanEnd

        public void OwnsChangeReturnsFalseIfChangeIsReplacementOrDeleteAtSpanEnd() {
            // Arrange
            Span span = new CodeSpan(new SourceLocation(42, 0, 42), "FooBarBaz");
            TextChange change = new TextChange(51, 2, new StringTextBuffer("BooBarBaz"), 3, new StringTextBuffer("Foo"));

            // Act/Assert
            Assert.IsFalse(span.OwnsChange(change));
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:8,代码来源:SpanTest.cs


示例6: OwnsChangeReturnsTrueIfChangeIsInsertionAtSpanEndAndCanGrowIsTrue

        public void OwnsChangeReturnsTrueIfChangeIsInsertionAtSpanEndAndCanGrowIsTrue() {
            // Arrange
            Span span = new CodeSpan(new SourceLocation(42, 0, 42), "FooBarBaz");
            TextChange change = new TextChange(51, 0, new StringTextBuffer("BooBarBaz"), 3, new StringTextBuffer("Foo"));

            // Act/Assert
            Assert.IsTrue(span.OwnsChange(change));
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:8,代码来源:SpanTest.cs


示例7: OwnsChangeReturnsFalseIfChangeStartsAfterSpanEnds

        public void OwnsChangeReturnsFalseIfChangeStartsAfterSpanEnds() {
            // Arrange
            Span span = new CodeSpan(new SourceLocation(42, 0, 42), "FooBarBaz");
            TextChange change = new TextChange(52, 3, new StringTextBuffer("BooBarBaz"), 3, new StringTextBuffer("Foo"));

            // Act/Assert
            Assert.IsFalse(span.OwnsChange(change));
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:8,代码来源:SpanTest.cs


示例8: OwnsChangeReturnsTrueIfSpanContentEntirelyContainsOldSpan

        public void OwnsChangeReturnsTrueIfSpanContentEntirelyContainsOldSpan() {
            // Arrange
            Span span = new CodeSpan(new SourceLocation(42, 0, 42), "FooBarBaz");
            TextChange change = new TextChange(45, 3, new StringTextBuffer("BooBarBaz"), 3, new StringTextBuffer("Foo"));

            // Act/Assert
            Assert.IsTrue(span.OwnsChange(change));
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:8,代码来源:SpanTest.cs


示例9: CheckForStructureChangesRequiresNonNullBufferInChange

        public void CheckForStructureChangesRequiresNonNullBufferInChange() {
            TextChange change = new TextChange();
            ExceptionAssert.ThrowsArgumentException(() => new RazorEditorParser(CreateHost(),
                                                                     "C:\\Foo.cshtml").CheckForStructureChanges(change),
                                                    "change",
                                                    String.Format(RazorResources.Structure_Member_CannotBeNull, "Buffer", "TextChange"));

        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:8,代码来源:RazorEditorParserTest.cs


示例10: TestIsInsert

        public void TestIsInsert() {
            // Arrange 
            ITextBuffer oldBuffer = new Mock<ITextBuffer>().Object;
            ITextBuffer newBuffer = new Mock<ITextBuffer>().Object;
            TextChange change = new TextChange(0, 0, oldBuffer, 35, newBuffer);

            // Assert
            Assert.IsTrue(change.IsInsert);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:9,代码来源:TextChangeTest.cs


示例11: TestIsReplace

        public void TestIsReplace() {
            // Arrange 
            ITextBuffer oldBuffer = new Mock<ITextBuffer>().Object;
            ITextBuffer newBuffer = new Mock<ITextBuffer>().Object;
            TextChange change = new TextChange(0, 5, oldBuffer, 10, newBuffer);

            // Assert
            Assert.IsTrue(change.IsReplace);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:9,代码来源:TextChangeTest.cs


示例12: TestIsDelete

        public void TestIsDelete()
        {
            // Arrange 
            ITextBuffer oldBuffer = new Mock<ITextBuffer>().Object;
            ITextBuffer newBuffer = new Mock<ITextBuffer>().Object;
            TextChange change = new TextChange(0, 1, oldBuffer, 0, newBuffer);

            // Assert
            Assert.True(change.IsDelete);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:TextChangeTest.cs


示例13: TestDeleteCreatesTheRightSizeChange

        public void TestDeleteCreatesTheRightSizeChange()
        {
            // Arrange 
            ITextBuffer oldBuffer = new Mock<ITextBuffer>().Object;
            ITextBuffer newBuffer = new Mock<ITextBuffer>().Object;
            TextChange change = new TextChange(0, 1, oldBuffer, 0, newBuffer);

            // Assert
            Assert.Equal(0, change.NewText.Length);
            Assert.Equal(1, change.OldText.Length);
        }
开发者ID:huyq2002,项目名称:aspnetwebstack,代码行数:11,代码来源:TextChangeTest.cs


示例14: ApplyChangeReturnsRejectedIfTerminatorStringNull

        public void ApplyChangeReturnsRejectedIfTerminatorStringNull() {
            // Arrange
            var span = new CodeSpan(new SourceLocation(0, 0, 0), "foo");
            var change = new TextChange(0, 0, new StringTextBuffer("foo"), 1, new StringTextBuffer("bfoo"));

            // Act
            PartialParseResult result = span.ApplyChange(change);

            // Assert
            Assert.AreEqual(PartialParseResult.Rejected, result);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:11,代码来源:CodeSpanTest.cs


示例15: CanAcceptChange

 protected override PartialParseResult CanAcceptChange(Span target, TextChange normalizedChange)
 {
     if (((AutoCompleteAtEndOfSpan && IsAtEndOfSpan(target, normalizedChange)) || IsAtEndOfFirstLine(target, normalizedChange)) &&
         normalizedChange.IsInsert &&
         ParserHelpers.IsNewLine(normalizedChange.NewText) &&
         AutoCompleteString != null)
     {
         return PartialParseResult.Rejected | PartialParseResult.AutoCompleteBlock;
     }
     return PartialParseResult.Rejected;
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:AutoCompleteEditHandler.cs


示例16: CanAcceptChange

        protected override PartialParseResult CanAcceptChange(Span target, TextChange normalizedChange)
        {
            if (AcceptedCharacters == AcceptedCharacters.Any)
            {
                return PartialParseResult.Rejected;
            }

            // In some editors intellisense insertions are handled as "dotless commits".  If an intellisense selection is confirmed 
            // via something like '.' a dotless commit will append a '.' and then insert the remaining intellisense selection prior 
            // to the appended '.'.  This 'if' statement attempts to accept the intermediate steps of a dotless commit via 
            // intellisense.  It will accept two cases:
            //     1. '@foo.' -> '@foobaz.'.
            //     2. '@foobaz..' -> '@foobaz.bar.'. Includes Sub-cases '@foobaz()..' -> '@foobaz().bar.' etc.
            // The key distinction being the double '.' in the second case.
            if (IsDotlessCommitInsertion(target, normalizedChange))
            {
                return HandleDotlessCommitInsertion(target);
            }

            if (IsAcceptableReplace(target, normalizedChange))
            {
                return HandleReplacement(target, normalizedChange);
            }
            int changeRelativePosition = normalizedChange.OldPosition - target.Start.AbsoluteIndex;

            // Get the edit context
            char? lastChar = null;
            if (changeRelativePosition > 0 && target.Content.Length > 0)
            {
                lastChar = target.Content[changeRelativePosition - 1];
            }

            // Don't support 0->1 length edits
            if (lastChar == null)
            {
                return PartialParseResult.Rejected;
            }

            // Accepts cases when insertions are made at the end of a span or '.' is inserted within a span.
            if (IsAcceptableInsertion(target, normalizedChange))
            {
                // Handle the insertion
                return HandleInsertion(target, lastChar.Value, normalizedChange);
            }

            if (IsAcceptableDeletion(target, normalizedChange))
            {
                return HandleDeletion(target, lastChar.Value, normalizedChange);
            }

            return PartialParseResult.Rejected;
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:52,代码来源:ImplicitExpressionEditHandler.cs


示例17: SpanWithAcceptTrailingDotOnAcceptsIntelliSenseReplaceWhichActuallyInsertsDot

        public void SpanWithAcceptTrailingDotOnAcceptsIntelliSenseReplaceWhichActuallyInsertsDot() {
            // Arrange
            var span = new ImplicitExpressionSpan("abcd", CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true, acceptedCharacters: AcceptedCharacters.None);
            var newBuffer = new StringTextBuffer("abcd.");
            var oldBuffer = new StringTextBuffer("abcd");
            var textChange = new TextChange(0, 4, oldBuffer, 5, newBuffer);

            // Act
            PartialParseResult result = span.ApplyChange(textChange);

            // Assert
            Assert.AreEqual(PartialParseResult.Accepted, result);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:13,代码来源:ImplciitExpressionSpanTest.cs


示例18: SpanWithAcceptTrailingDotOffProvisionallyAcceptsEndReplacementWithTrailingDot

        public void SpanWithAcceptTrailingDotOffProvisionallyAcceptsEndReplacementWithTrailingDot() {
            // Arrange
            var span = new ImplicitExpressionSpan("abcd.", CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false, acceptedCharacters: AcceptedCharacters.None);
            var newBuffer = new StringTextBuffer("abcdef.");
            var oldBuffer = new StringTextBuffer("abcd.");
            var textChange = new TextChange(0, 5, oldBuffer, 7, newBuffer);

            // Act
            PartialParseResult result = span.ApplyChange(textChange);            

            // Assert
            Assert.AreEqual(PartialParseResult.Accepted | PartialParseResult.Provisional, result);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:13,代码来源:ImplciitExpressionSpanTest.cs


示例19: CodeSpan

        public void ApplyChangeReturnsRejectedWithoutAutoCompleteBlockIfTerminatorStringNonNullAndEditIsNewlineInsertOnSecondLine() {
            // Arrange
            var span = new CodeSpan(new SourceLocation(0, 0, 0), "foo\r\nbar\r\nbaz") {
                AutoCompleteString = "}"
            };
            var change = new TextChange(8, 0, new StringTextBuffer("foo\r\nbar\r\nbaz"), 2, new StringTextBuffer("foo\r\nb\r\nar\r\nbaz"));

            // Act
            PartialParseResult result = span.ApplyChange(change);

            // Assert
            Assert.AreEqual(PartialParseResult.Rejected, result);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:13,代码来源:CodeSpanTest.cs


示例20: ConstructorInitializesProperties

        public void ConstructorInitializesProperties() {
            // Act
            ITextBuffer oldBuffer = new Mock<ITextBuffer>().Object;
            ITextBuffer newBuffer = new Mock<ITextBuffer>().Object;
            TextChange change = new TextChange(42, 24, oldBuffer, 1337, newBuffer);

            // Assert
            Assert.AreEqual(42, change.OldPosition);
            Assert.AreEqual(24, change.OldLength);
            Assert.AreEqual(1337, change.NewLength);
            Assert.AreSame(newBuffer, change.NewBuffer);
            Assert.AreSame(oldBuffer, change.OldBuffer);
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:13,代码来源:TextChangeTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Routing.RequestContext类代码示例发布时间:2022-05-26
下一篇:
C# SyntaxTree.Span类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap