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


C# DocumentBuilder.InsertRun方法代码示例

本文整理汇总了C#中DocumentBuilder.InsertRun方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.InsertRun方法的具体用法?C# DocumentBuilder.InsertRun怎么用?C# DocumentBuilder.InsertRun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.InsertRun方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeDocText_HyperlinkQueryString

        public void MergeDocText_HyperlinkQueryString()
        {
            var doc = new Document();

            var builder = new DocumentBuilder(doc);

            builder.InsertRun("^ ");

            builder.InsertField("HYPERLINK \"https://google.com/q=%7b%7bQuery%7d%7d\"");

            builder.InsertRun(" $");

            doc.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                        <Run>^ </Run>
                        <FieldStart></FieldStart>
                        <Run>HYPERLINK ""https://google.com/q=%7b%7bQuery%7d%7d""</Run>
                        <FieldSeparator></FieldSeparator>
                        <FieldEnd></FieldEnd>
                        <Run> $</Run>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");

            var data = new
            {
                Query = "Arnold Schwarzenegger",
            };

            doc.Merge(data);

            doc.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                        <Run>^ </Run>
                        <FieldStart></FieldStart>
                        <Run>HYPERLINK ""</Run>
                        <Run>https://google.com/q=</Run>
                        <Run>Arnold%20Schwarzenegger</Run>
                        <Run>""</Run>
                        <FieldSeparator></FieldSeparator>
                        <FieldEnd></FieldEnd>
                        <Run> $</Run>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:56,代码来源:NodeTextMergeTests.cs

示例2: FromStrings

        public static Document FromStrings(string[] strings, out Run[] runs)
        {
            var builder = new DocumentBuilder();

            var runList = new List<Run>();

            var comments = new Dictionary<string, Comment>();

            foreach (var str in strings)
            {
                // Bookmark
                if (str.StartsWith("@{") && str.EndsWith("}"))
                {
                    if (str.StartsWith("@{/"))
                    {
                        var bookmarkName = str.Substring(3, str.Length - 4);
                        builder.EndBookmark(bookmarkName);
                    }
                    else
                    {
                        var bookmarkName = str.Substring(2, str.Length - 3);
                        builder.StartBookmark(bookmarkName);
                    }

                    continue;
                }

                // Comment
                if (str.StartsWith("!{") && str.EndsWith("}"))
                {
                    if (str.StartsWith("!{/"))
                    {
                        var commentName = str.Substring(3, str.Length - 4);

                        var comment = comments[commentName];

                        var commentEnd = new CommentRangeEnd(builder.Document, comment.Id);

                        builder.InsertNode(commentEnd);
                    }
                    else
                    {
                        var commentName = str.Substring(2, str.Length - 3);

                        var comment = new Comment(builder.Document, "", "", DateTime.Now);

                        comments.Add(commentName, comment);

                        comment.SetText("Comment: " + commentName);

                        builder.InsertNode(comment);

                        var commentStart = new CommentRangeStart(builder.Document, comment.Id);

                        builder.InsertNode(commentStart);
                    }

                    continue;
                }

                runList.Add(builder.InsertRun(str));
            }

            runs = runList.ToArray();

            return builder.Document;
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:67,代码来源:DocumentConverter.cs

示例3: MergeDocText_HyperlinkUrl

        public void MergeDocText_HyperlinkUrl()
        {
            var doc = new Document();

            var builder = new DocumentBuilder(doc);

            builder.InsertRun("^ ");

            builder.InsertField("HYPERLINK \"%7b%7bUrl%7d%7d\"");

            builder.InsertRun(" $");

            doc.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                        <Run>^ </Run>
                        <FieldStart></FieldStart>
                        <Run>HYPERLINK ""%7b%7bUrl%7d%7d""</Run>
                        <FieldSeparator></FieldSeparator>
                        <FieldEnd></FieldEnd>
                        <Run> $</Run>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");

            var data = new
            {
                Url = "https://www.google.com",
            };

            doc.Merge(data);

            doc.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                        <Run>^ </Run>
                        <FieldStart></FieldStart>
                        <Run>HYPERLINK ""</Run>
                        <Run>https://www.google.com</Run>
                        <Run>""</Run>
                        <FieldSeparator></FieldSeparator>
                        <FieldEnd></FieldEnd>
                        <Run> $</Run>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:55,代码来源:NodeTextMergeTests.cs


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