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


C# Text.TextChange类代码示例

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


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


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