當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。