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

C# Text.TextChange类代码示例

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

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



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

示例1: 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:KennyBu,项目名称:Razor,代码行数:7,代码来源:SpanEditHandler.cs


示例2: 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:KennyBu,项目名称:Razor,代码行数:34,代码来源:RazorDebugHelpers.cs


示例3: 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:KennyBu,项目名称:Razor,代码行数:10,代码来源:TextChangeTest.cs


示例4: 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:KennyBu,项目名称:Razor,代码行数:11,代码来源:TextChangeTest.cs


示例5: 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:rohitpoudel,项目名称:Razor,代码行数:11,代码来源:AutoCompleteEditHandler.cs


示例6: 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);
            }
            var 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:billwaddyjr,项目名称:Razor,代码行数:52,代码来源:ImplicitExpressionEditHandler.cs


示例7: 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.Equal(42, change.OldPosition);
            Assert.Equal(24, change.OldLength);
            Assert.Equal(1337, change.NewLength);
            Assert.Same(newBuffer, change.NewBuffer);
            Assert.Same(oldBuffer, change.OldBuffer);
        }
开发者ID:KennyBu,项目名称:Razor,代码行数:14,代码来源:TextChangeTest.cs


示例8: ApplyChange

        public virtual EditResult ApplyChange(Span target, TextChange change, bool force)
        {
            PartialParseResult result = PartialParseResult.Accepted;
            TextChange normalized = change.Normalize();
            if (!force)
            {
                result = CanAcceptChange(target, normalized);
            }

            // If the change is accepted then apply the change
            if (result.HasFlag(PartialParseResult.Accepted))
            {
                return new EditResult(result, UpdateSpan(target, normalized));
            }
            return new EditResult(result, new SpanBuilder(target));
        }
开发者ID:KennyBu,项目名称:Razor,代码行数:16,代码来源:SpanEditHandler.cs


示例9: UpdateSpan

 protected virtual SpanBuilder UpdateSpan(Span target, TextChange normalizedChange)
 {
     string newContent = normalizedChange.ApplyChange(target);
     SpanBuilder newSpan = new SpanBuilder(target);
     newSpan.ClearSymbols();
     foreach (ISymbol sym in Tokenizer(newContent))
     {
         sym.OffsetStart(target.Start);
         newSpan.Accept(sym);
     }
     if (target.Next != null)
     {
         SourceLocation newEnd = SourceLocationTracker.CalculateNewLocation(target.Start, newContent);
         target.Next.ChangeStart(newEnd);
     }
     return newSpan;
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:17,代码来源:SpanEditHandler.cs


示例10: LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan

        public void LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan()
        {
            // Arrange
            var factory = SpanFactory.CreateCsHtml();
            var block = new MarkupBlock(
                factory.Markup("Foo "),
                new StatementBlock(
                    factory.CodeTransition(),
                    factory.Code("bar").AsStatement()),
                factory.Markup(" Baz"));
            var change = new TextChange(128, 1, new StringTextBuffer("Foo @bar Baz"), 1, new StringTextBuffer("Foo @bor Baz"));

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

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


示例11: IsAcceptableEndInsertion

        // Accepts character insertions at the end of spans.  AKA: '@foo' -> '@fooo' or '@foo' -> '@foo   ' etc.
        private static bool IsAcceptableEndInsertion(Span target, TextChange change)
        {
            Debug.Assert(change.IsInsert);

            return IsAtEndOfSpan(target, change) ||
                   RemainingIsWhitespace(target, change);
        }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:8,代码来源:ImplicitExpressionEditHandler.cs


示例12: IsAcceptableInsertion

 // Acceptable insertions can occur at the end of a span or when a '.' is inserted within a span.
 private static bool IsAcceptableInsertion(Span target, TextChange change)
 {
     return change.IsInsert &&
            (IsAcceptableEndInsertion(target, change) ||
            IsAcceptableInnerInsertion(target, change));
 }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:7,代码来源:ImplicitExpressionEditHandler.cs


示例13: IsAtEndOfSpan

 protected internal static bool IsAtEndOfSpan(Span target, TextChange change)
 {
     return (change.OldPosition + change.OldLength) == (target.Start.AbsoluteIndex + target.Length);
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:4,代码来源:SpanEditHandler.cs


示例14: HandleInsertionAfterDot

 private PartialParseResult HandleInsertionAfterDot(Span target, TextChange change)
 {
     // If the insertion is a full identifier or another dot, accept it
     if (ParserHelpers.IsIdentifier(change.NewText) || change.NewText == ".")
     {
         return TryAcceptChange(target, change);
     }
     return PartialParseResult.Rejected;
 }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:9,代码来源:ImplicitExpressionEditHandler.cs


示例15: HandleInsertion

 private PartialParseResult HandleInsertion(Span target, char previousChar, TextChange change)
 {
     // What are we inserting after?
     if (previousChar == '.')
     {
         return HandleInsertionAfterDot(target, change);
     }
     else if (ParserHelpers.IsIdentifierPart(previousChar) || previousChar == ')' || previousChar == ']')
     {
         return HandleInsertionAfterIdPart(target, change);
     }
     else
     {
         return PartialParseResult.Rejected;
     }
 }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:16,代码来源:ImplicitExpressionEditHandler.cs


示例16: HandleReplacement

        private PartialParseResult HandleReplacement(Span target, TextChange change)
        {
            // Special Case for IntelliSense commits.
            //  When IntelliSense commits, we get two changes (for example user typed "Date", then committed "DateTime" by pressing ".")
            //  1. Insert "." at the end of this span
            //  2. Replace the "Date." at the end of the span with "DateTime."
            //  We need partial parsing to accept case #2.
            var oldText = GetOldText(target, change);

            var result = PartialParseResult.Rejected;
            if (EndsWithDot(oldText) && EndsWithDot(change.NewText))
            {
                result = PartialParseResult.Accepted;
                if (!AcceptTrailingDot)
                {
                    result |= PartialParseResult.Provisional;
                }
            }
            return result;
        }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:20,代码来源:ImplicitExpressionEditHandler.cs


示例17: CanAcceptChange

 protected virtual PartialParseResult CanAcceptChange(Span target, TextChange normalizedChange)
 {
     return PartialParseResult.Rejected;
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:4,代码来源:SpanEditHandler.cs


示例18: GetOldText

 /// <summary>
 /// Returns the old text referenced by the change.
 /// </summary>
 /// <remarks>
 /// If the content has already been updated by applying the change, this data will be _invalid_
 /// </remarks>
 protected internal static string GetOldText(Span target, TextChange change)
 {
     return target.Content.Substring(change.OldPosition - target.Start.AbsoluteIndex, change.OldLength);
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:10,代码来源:SpanEditHandler.cs


示例19: IsAcceptableInnerInsertion

        private static bool IsAcceptableInnerInsertion(Span target, TextChange change)
        {
            Debug.Assert(change.IsInsert);

            // Ensure that we're actually inserting in the middle of a span and not at the end.
            // This case will fail if the IsAcceptableEndInsertion does not capture an end insertion correctly.
            Debug.Assert(!IsAtEndOfSpan(target, change));

            return change.NewPosition > 0 &&
                   change.NewText == ".";
        }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:11,代码来源:ImplicitExpressionEditHandler.cs


示例20: RemainingIsWhitespace

 private static bool RemainingIsWhitespace(Span target, TextChange change)
 {
     var offset = (change.OldPosition - target.Start.AbsoluteIndex) + change.OldLength;
     return String.IsNullOrWhiteSpace(target.Content.Substring(offset));
 }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:5,代码来源:ImplicitExpressionEditHandler.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Routing.RouteContext类代码示例发布时间:2022-05-26
下一篇:
C# Framework.MarkupBlock类代码示例发布时间: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