Beispiel #1
0
        public override Result VisitPlainText([NotNull] PlainTextContext context)
        {
            var sqlText    = SqlTextUtil.Parse(context.GetToken(SQLText, 0).GetText());
            var csharpText = SqlTextUtil.ToCSharpString(sqlText);

            _writer.WriteIndentLine($"sb.Append({csharpText});");
            return(Result.Ok());
        }
Beispiel #2
0
        public override Result VisitPlainText([NotNull] PlainTextContext context)
        {
            var text = SqlTextUtil.Parse(context.GetToken(SQLText, 0).GetText());

            _il.Emit(OpCodes.Ldloc_0);                                             // sb
            _il.Emit(OpCodes.Ldstr, text);                                         // sb str
            _il.Emit(OpCodes.Call, _appendCall);                                   // [empty]
            return(Result.Ok());
        }
Beispiel #3
0
        public override Result VisitPlainText([NotNull] PlainTextContext context)
        {
            var text = context.GetToken(SQLText, 0);

            _il.Emit(OpCodes.Ldloc_0);                                             // sb
            _il.Emit(OpCodes.Ldstr, text.GetText());                               // sb str
            _il.Emit(OpCodes.Call, typeof(StringBuilder)
                     .GetTypeInfo().GetMethod(nameof(StringBuilder.Append),
                                              new[] { typeof(string), }));         // sb+str
            _il.Emit(OpCodes.Pop);                                                 // [empty]
            return(Result.Ok());
        }
Beispiel #4
0
        public void OnPlainText(PlainTextContext context)
        {
            bool matched = false;

            if (index == 5)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), "Edit People");
            }
            if (index == 13)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), "PersonID:");
            }
            if (index == 17)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), "LastName:");
            }
            if (index == 22)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), " ");
            }
            if (index == 24)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), "TEST1");
            }
            if (index == 26)
            {
                matched = true;
                Assert.IsFalse(context.WithinClientSideComment);
                Assert.AreEqual(context.Text.Trim(), "TEST2");
            }
            Assert.IsTrue(matched);
            index++;
        }
        /// <summary>
        /// Called after plain text (between elements) is read
        /// </summary>
        public void OnPlainText(PlainTextContext context)
        {
            if (parentCommand is BatchMoveCommand)   // no resource references can be directly in the attributes, safe to look only for string literals
            // add whole text to results
            {
                var newItem = AddResult(new AttributeInfo()
                {
                    BlockSpan = context.BlockSpan, Name = context.Text, Value = context.Text
                },
                                        null, null, context.WithinClientSideComment, false, false, false);
                if (newItem != null)
                {
                    newItem.ComesFromPlainText = true;
                    newItem.ComesFromElement   = false;

                    if (openedElements.Count > 0)
                    {
                        ElementContext element = openedElements.Peek();
                        newItem.ElementName   = element.ElementName;
                        newItem.ElementPrefix = element.Prefix;
                    }
                }
            }
        }