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


C# Document.Accept方法代码示例

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


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

示例1: Run

        public static void Run()
        {
            // ExStart:ExtractContentUsingDocumentVisitor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();

            // Open the document we want to convert.
            Document doc = new Document(dataDir + "Visitor.ToText.doc");

            // Create an object that inherits from the DocumentVisitor class.
            MyDocToTxtWriter myConverter = new MyDocToTxtWriter();

            // This is the well known Visitor pattern. Get the model to accept a visitor.
            // The model will iterate through itself by calling the corresponding methods
            // On the visitor object (this is called visiting).
            // 
            // Note that every node in the object model has the Accept method so the visiting
            // Can be executed not only for the whole document, but for any node in the document.
            doc.Accept(myConverter);

            // Once the visiting is complete, we can retrieve the result of the operation,
            // That in this example, has accumulated in the visitor.
            Console.WriteLine(myConverter.GetText());
            // ExEnd:ExtractContentUsingDocumentVisitor
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:25,代码来源:ExtractContentUsingDocumentVisitor.cs

示例2: AddsBodyToSection_WhenStartVisitingFromSection

        public void AddsBodyToSection_WhenStartVisitingFromSection()
        {
            Section section = new Document().FirstSection;
            var sectionProxy = new SectionProxy();
            var bodyProxy = A.Fake<BodyProxy>();

            A.CallTo(() => this.proxyFactory.CreateSection()).Returns(sectionProxy);
            A.CallTo(() => this.proxyFactory.CreateBody()).Returns(bodyProxy);

            section.Accept(this.testee);

            sectionProxy.Body.Should().Be(bodyProxy);
        }
开发者ID:philippdolder,项目名称:AsposeVisualizer,代码行数:13,代码来源:ProxyDocumentVisitorFacts.cs

示例3: ToText

        //ExStart
        //ExFor:Document.Accept
        //ExFor:Body.Accept
        //ExFor:DocumentVisitor
        //ExFor:DocumentVisitor.VisitAbsolutePositionTab
        //ExFor:DocumentVisitor.VisitBookmarkStart 
        //ExFor:DocumentVisitor.VisitBookmarkEnd
        //ExFor:DocumentVisitor.VisitRun
        //ExFor:DocumentVisitor.VisitFieldStart
        //ExFor:DocumentVisitor.VisitFieldEnd
        //ExFor:DocumentVisitor.VisitFieldSeparator
        //ExFor:DocumentVisitor.VisitBodyStart
        //ExFor:DocumentVisitor.VisitBodyEnd
        //ExFor:DocumentVisitor.VisitParagraphEnd
        //ExFor:DocumentVisitor.VisitHeaderFooterStart
        //ExFor:VisitorAction
        //ExId:ExtractContentDocToTxtConverter
        //ExSummary:Shows how to use the Visitor pattern to add new operations to the Aspose.Words object model. In this case we create a simple document converter into a text format.
        public void ToText()
        {
            // Open the document we want to convert.
            Document doc = new Document(MyDir + "Visitor.ToText.doc");

            // Create an object that inherits from the DocumentVisitor class.
            MyDocToTxtWriter myConverter = new MyDocToTxtWriter();

            // This is the well known Visitor pattern. Get the model to accept a visitor.
            // The model will iterate through itself by calling the corresponding methods
            // on the visitor object (this is called visiting).
            // 
            // Note that every node in the object model has the Accept method so the visiting
            // can be executed not only for the whole document, but for any node in the document.
            doc.Accept(myConverter);

            // Once the visiting is complete, we can retrieve the result of the operation,
            // that in this example, has accumulated in the visitor.
            Console.WriteLine(myConverter.GetText());
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:38,代码来源:ExVisitor.cs

示例4: Convert

		public Document Convert(Document document)
		{
			document.Accept(this);
			return _newDocument;
		}
开发者ID:RossLieberman,项目名称:NEST,代码行数:5,代码来源:GeneratedAsciidocVisitor.cs

示例5: SetsSectionAsRoot_WhenStartVisitingFromSection

        public void SetsSectionAsRoot_WhenStartVisitingFromSection()
        {
            Section section = new Document().FirstSection;
            var sectionProxy = A.Fake<SectionProxy>();

            A.CallTo(() => this.proxyFactory.CreateSection()).Returns(sectionProxy);

            section.Accept(this.testee);

            this.testee.Root.Should().Be(sectionProxy);
        }
开发者ID:philippdolder,项目名称:AsposeVisualizer,代码行数:11,代码来源:ProxyDocumentVisitorFacts.cs

示例6: SetsParagraphAsRoot_WhenStartVisitingFromParagraph

        public void SetsParagraphAsRoot_WhenStartVisitingFromParagraph()
        {
            Paragraph paragraph = new Document().FirstSection.Body.FirstParagraph;

            var paragraphProxy = A.Fake<ParagraphProxy>();

            A.CallTo(() => this.proxyFactory.CreateParagraph()).Returns(paragraphProxy);

            paragraph.Accept(this.testee);

            this.testee.Root.Should().Be(paragraphProxy);
        }
开发者ID:philippdolder,项目名称:AsposeVisualizer,代码行数:12,代码来源:ProxyDocumentVisitorFacts.cs

示例7: SetsDocumentAsRoot_WhenStartVisitingFromDocument

        public void SetsDocumentAsRoot_WhenStartVisitingFromDocument()
        {
            var document = new Document();
            var documentProxy = new DocumentProxy();

            A.CallTo(() => this.proxyFactory.CreateDocument()).Returns(documentProxy);

            document.Accept(this.testee);

            this.testee.Root.Should().Be(documentProxy);
        }
开发者ID:philippdolder,项目名称:AsposeVisualizer,代码行数:11,代码来源:ProxyDocumentVisitorFacts.cs

示例8: SetsBodyAsRoot_WhenStartVisitingFromBody

        public void SetsBodyAsRoot_WhenStartVisitingFromBody()
        {
            Body body = new Document().FirstSection.Body;
            var bodyProxy = A.Fake<BodyProxy>();

            A.CallTo(() => this.proxyFactory.CreateBody()).Returns(bodyProxy);

            body.Accept(this.testee);

            this.testee.Root.Should().Be(bodyProxy);
        }
开发者ID:philippdolder,项目名称:AsposeVisualizer,代码行数:11,代码来源:ProxyDocumentVisitorFacts.cs

示例9: PrintHorizontalAndVerticalMerged

        public static void PrintHorizontalAndVerticalMerged(string dataDir)
        {
            // ExStart:PrintHorizontalAndVerticalMerged
            Document doc = new Document(dataDir + "Table.MergedCells.doc");

            // Create visitor
            SpanVisitor visitor = new SpanVisitor(doc);

            // Accept visitor
            doc.Accept(visitor);
            // ExEnd:PrintHorizontalAndVerticalMerged
            Console.WriteLine("\nHorizontal and vertical merged of a cell prints successfully.");
           
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:14,代码来源:MergedCells.cs

示例10: RemoveHiddenContentFromDocument

        //ExStart
        //ExFor:Font.Hidden
        //ExFor:Paragraph.Accept
        //ExFor:DocumentVisitor.VisitParagraphStart(Aspose.Words.Paragraph)
        //ExFor:DocumentVisitor.VisitFormField(Aspose.Words.Fields.FormField)
        //ExFor:DocumentVisitor.VisitTableEnd(Aspose.Words.Tables.Table)
        //ExFor:DocumentVisitor.VisitCellEnd(Aspose.Words.Tables.Cell)
        //ExFor:DocumentVisitor.VisitRowEnd(Aspose.Words.Tables.Row)
        //ExFor:DocumentVisitor.VisitSpecialChar(Aspose.Words.SpecialChar)
        //ExFor:DocumentVisitor.VisitGroupShapeStart(Aspose.Words.Drawing.GroupShape)
        //ExFor:DocumentVisitor.VisitShapeStart(Aspose.Words.Drawing.Shape)
        //ExFor:DocumentVisitor.VisitCommentStart(Aspose.Words.Comment)
        //ExFor:DocumentVisitor.VisitFootnoteStart(Aspose.Words.Footnote)
        //ExFor:SpecialChar
        //ExFor:Node.Accept
        //ExFor:Paragraph.ParagraphBreakFont
        //ExFor:Table.Accept
        //ExSummary:Implements the Visitor Pattern to remove all content formatted as hidden from the document.
        public void RemoveHiddenContentFromDocument()
        {
            // Open the document we want to remove hidden content from.
            Document doc = new Document(MyDir + "Font.Hidden.doc");

            // Create an object that inherits from the DocumentVisitor class.
            RemoveHiddenContentVisitor hiddenContentRemover = new RemoveHiddenContentVisitor();

            // This is the well known Visitor pattern. Get the model to accept a visitor.
            // The model will iterate through itself by calling the corresponding methods
            // on the visitor object (this is called visiting).

            // We can run it over the entire the document like so:
            doc.Accept(hiddenContentRemover);

            // Or we can run it on only a specific node.
            Paragraph para = (Paragraph)doc.GetChild(NodeType.Paragraph, 4, true);
            para.Accept(hiddenContentRemover);

            // Or over a different type of node like below.
            Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
            table.Accept(hiddenContentRemover);

            doc.Save(MyDir + @"\Artifacts\Font.Hidden.doc");

            Assert.AreEqual(13, doc.GetChildNodes(NodeType.Paragraph, true).Count); //ExSkip
            Assert.AreEqual(1, doc.GetChildNodes(NodeType.Table, true).Count); //ExSkip
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:46,代码来源:ExFont.cs


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