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


C# ParsingContext.SetDefaultStartContext方法代码示例

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


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

示例1: TestLoopbackSimpleRTFTableGetsTable

        public void TestLoopbackSimpleRTFTableGetsTable()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "SimpleRTFTable_document.xml", FileMode.Open))
            {
                FcsToRtfWriter writerOut = new FcsToRtfWriter();
                writerOut.RememberElementsWritten = true;

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();

                List<DocElement> elemsBefore = writerOut.ListOfWrittenElements();

                Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader();
                readBack.ExtractRTFFileCollectionFromWriter(writerOut);

                List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection();
                int iCountBefore = elemsBefore.Count;
                int iCountAfter  = elemsAfter.Count;
                Assert.IsTrue(iCountAfter <= iCountBefore, "Seem to have invented extra elements in teh loop back"); 
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:TestRTFTableBuilder.cs

示例2: TestGeneratesSectionObjects

        public void TestGeneratesSectionObjects()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentHasTwoSections.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                DocElement de = null;
                int iObjectCount = writerOut.FileCollectionSize();
                for(int iIndex = 0; iIndex < iObjectCount; ++iIndex)
                {
                    de = writerOut.ReadBackElementFromFileCollection(iIndex);
                    if (de == null)
                        continue;
                    if (de.GetType() == typeof(Section))
                        break;
                    de = null;
                }
                Assert.IsNotNull(de, "Failed to find any Section objects in the output");
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:TestSectionFormatting.cs

示例3: TestReadBackCharacterFormattingIncludesColourInfo

        public void TestReadBackCharacterFormattingIncludesColourInfo()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "CharacterPropertiesTestDocument.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                int iReadBackIndex = 2;
                DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.None);
                iReadBackIndex += 3;  
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.Continuous);
                iReadBackIndex += 4;  
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.None);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:TestReadbackFCSObjectsFromRTFFileCollection.cs

示例4: TestRTFTableBuilder

        public void TestRTFTableBuilder()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "CharacterPropertiesTestDocument.xml", FileMode.Open))
            {
                FcsToRtfWriter writerOut = new FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                context.ParsingBody = true;
                pft.Parse();
//                RTFTableBuilder rtfTable = writerOut.GetRTFTableBuilder();
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:15,代码来源:TestRTFWriter.cs

示例5: TestReadBackSectionObjects

        public void TestReadBackSectionObjects()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentHasTwoSections.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.EmitContextStart();
                pft.Parse();

                int iFoundNSectionsWhereN = 0;
                int iObjectCount = writerOut.FileCollectionSize();
                for (int iIndex = 0; iIndex < iObjectCount; ++iIndex)
                {
                    DocElement des = writerOut.ReadBackElementFromFileCollection(iIndex);
                    if (des == null)
                        continue;
                    if(des.GetType() == typeof(Section))
                        ++iFoundNSectionsWhereN;
                }
                Assert.IsTrue(iFoundNSectionsWhereN == 2); 

                int iReadBackIndex = 0;
                DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(Section));
                Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.TopMargin);
                Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.RightMargin);
                Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.BottomMargin);
                Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.LeftMargin);

                iReadBackIndex += 6; 
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(Section));
                Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.TopMargin);
                Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.RightMargin);
                Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.BottomMargin);
                Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.LeftMargin);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:43,代码来源:TestReadbackFCSObjectsFromRTFFileCollection.cs

示例6: TestParagraphWithBorders

        public void TestParagraphWithBorders()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "Test paragraph borders document.xml", FileMode.Open))
            {
                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null);

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                List<DocElement> elemsRead = writerOut.Elements;

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[0].Type);
                Assert.IsNotNull((elemsRead[0] as Paragraph).ParagraphFormatting);
                BorderDefinition bDef = (elemsRead[0] as Paragraph).ParagraphFormatting.Borders;
                Assert.IsNotNull(bDef);
                Assert.IsNotNull(bDef.Top);
                Assert.IsNotNull(bDef.Left);
                Assert.IsNotNull(bDef.Bottom);
                Assert.IsNotNull(bDef.Right);

                Border borderTop = bDef.Top;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTop.BorderLineStyle);
                Assert.AreEqual(4, borderTop.PenWidth);

                Border borderLeft = bDef.Left;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderLeft.BorderLineStyle);
                Assert.AreEqual(4, borderLeft.PenWidth);

                Border borderBottom = bDef.Bottom;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderBottom.BorderLineStyle);
                Assert.AreEqual(4, borderBottom.PenWidth);

                Border borderRight = bDef.Right;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderRight.BorderLineStyle);
                Assert.AreEqual(4, borderRight.PenWidth);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:40,代码来源:TestParagraphProperties.cs

示例7: TestAlignment

        public void TestAlignment()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "ParagraphPropertiesTestDocument.xml", FileMode.Open))
            {
                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null);

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                List<DocElement> elemsRead = writerOut.Elements;

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[ 0].Type);
                ParagraphProperties parProps1 = (elemsRead[ 0] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps1.ParaAlignment == ParagraphProperties.AlignmentStyles.None);

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[ 5].Type);
                ParagraphProperties parProps2 = (elemsRead[ 5] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps2.ParaAlignment == ParagraphProperties.AlignmentStyles.Centre);

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[10].Type);
                ParagraphProperties parProps3 = (elemsRead[10] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps3.ParaAlignment == ParagraphProperties.AlignmentStyles.None);

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[15].Type);
                ParagraphProperties parProps4 = (elemsRead[15] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps4.ParaAlignment == ParagraphProperties.AlignmentStyles.Left);

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[20].Type);
                ParagraphProperties parProps5 = (elemsRead[20] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps5.ParaAlignment == ParagraphProperties.AlignmentStyles.Right);

                Assert.AreEqual(DocElementTypes.WPparagraph, elemsRead[25].Type);
                ParagraphProperties parProps6 = (elemsRead[25] as Paragraph).ParagraphFormatting.ParagraphProperties;
                Assert.IsTrue(parProps1.ParaAlignment == ParagraphProperties.AlignmentStyles.None);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:39,代码来源:TestParagraphProperties.cs

示例8: TestLoopbackSimpleRTFTableGetsGridInfo

        public void TestLoopbackSimpleRTFTableGetsGridInfo()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "SimpleRTFTable_document.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();
                writerOut.RememberElementsWritten = true;

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();

                List<DocElement> elemsBefore = writerOut.ListOfWrittenElements();

                Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader();
                readBack.ExtractRTFFileCollectionFromWriter(writerOut);

                List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection();
                int iCountBefore = elemsBefore.Count;
                int iCountAfter = elemsAfter.Count;

                // At 28-11-2007 count was 15, which is wrong, but will evolve to correctednessness with time, cups of coffee and several Hob Nobbs
                int iIndex = 14;
                Assert.AreEqual(DocElementTypes.WPtable, elemsAfter[iIndex].Type);
                Table tableEnd = elemsAfter[iIndex] as Table;
                Assert.IsFalse(tableEnd.IsStart);
                Assert.IsTrue(tableEnd.IsEnd);
                TableGrid grid = tableEnd.TableGrid;
                Assert.IsNotNull(grid);
                Assert.IsNotNull(grid.ColumnWidths);
                Assert.AreEqual(2, grid.ColumnWidths.Count);
                Assert.AreEqual(1242, grid.ColumnWidths[0]);
                Assert.AreEqual(993, grid.ColumnWidths[1]);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:37,代码来源:TestRTFTableBuilder.cs

示例9: TestLoopbackRTFTableGetsTableBorderInfo

        public void TestLoopbackRTFTableGetsTableBorderInfo()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentWithExplicitTableBorder.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();
                writerOut.RememberElementsWritten = true;

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();

                List<DocElement> elemsBefore = writerOut.ListOfWrittenElements();

                Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader();
                readBack.ExtractRTFFileCollectionFromWriter(writerOut);

                List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection();
                int iCountBefore = elemsBefore.Count;
                int iCountAfter = elemsAfter.Count;

                int iIndex = 14;
                Assert.AreEqual(DocElementTypes.WPtable, elemsAfter[iIndex].Type);
                Table tableEnd = elemsAfter[iIndex] as Table;

                Assert.IsFalse(tableEnd.IsStart);
                Assert.IsTrue(tableEnd.IsEnd);

                Assert.IsNotNull(tableEnd.TableProperties);
                Assert.IsNotNull(tableEnd.TableProperties.TableBorders);
                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Top);
                Border borderTableTop = tableEnd.TableProperties.TableBorders.Top;
                Assert.AreEqual(Border.BorderStyle.Dashed, borderTableTop.BorderLineStyle);
                Assert.AreEqual(8, borderTableTop.PenWidth);

                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Left);
                Border borderTableLeft = tableEnd.TableProperties.TableBorders.Left;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableLeft.BorderLineStyle);
                Assert.AreEqual(8, borderTableLeft.PenWidth);

                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Bottom);
                Border borderTableBottom = tableEnd.TableProperties.TableBorders.Bottom;
                Assert.AreEqual(Border.BorderStyle.None, borderTableBottom.BorderLineStyle);
                Assert.AreEqual(0, borderTableBottom.PenWidth);

                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Right);
                Border borderTableRight = tableEnd.TableProperties.TableBorders.Right;
                Assert.AreEqual(Border.BorderStyle.Double, borderTableRight.BorderLineStyle);
                Assert.AreEqual(8, borderTableRight.PenWidth);

                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.HorizontalInside);
                Border borderTableHorizontalInside = tableEnd.TableProperties.TableBorders.HorizontalInside;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableHorizontalInside.BorderLineStyle);
                Assert.AreEqual(4, borderTableHorizontalInside.PenWidth);

                Assert.IsNotNull(tableEnd.TableProperties.TableBorders.VerticalInside);
                Border borderTableVerticalInside = tableEnd.TableProperties.TableBorders.VerticalInside;
                Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableVerticalInside.BorderLineStyle);
                Assert.AreEqual(6, borderTableVerticalInside.PenWidth);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:63,代码来源:TestRTFTableBuilder.cs

示例10: TestReadBackCharacterFormatting_2

        public void TestReadBackCharacterFormatting_2()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "Test Additional Character Properties Document.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                int iReadBackIndex = 4;
                DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.StrikeThrough, "Expected strikethrough");
                
                iReadBackIndex = 8;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.DoubleStrikeThrough, "Expected DoubleStrikeThrough");
                
                iReadBackIndex = 12;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Superscript, "Expected Superscript");

                iReadBackIndex = 16;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Subscript, "Expected Subscript");
                Assert.IsFalse((de as CharacterFormatting).Properties.Superscript, "Expected Superscript to be off now");

                iReadBackIndex = 20;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Shadow, "Expected Shadow");
                Assert.IsFalse((de as CharacterFormatting).Properties.Subscript, "Expected Subscript to be off now");
                Assert.IsFalse((de as CharacterFormatting).Properties.Superscript, "Expected Superscript to be off now");

                iReadBackIndex = 24;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Outline, "Expected Outline");

                iReadBackIndex = 28;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Emboss, "Expected Emboss");

                iReadBackIndex = 32;
                de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(CharacterFormatting));
                Assert.IsTrue((de as CharacterFormatting).Properties.Engrave, "Expected Engrave");
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:55,代码来源:TestReadbackFCSObjectsFromRTFFileCollection.cs

示例11: TestReadBackTableObject

        public void TestReadBackTableObject()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentWithASimpleTable.xml", FileMode.Open))
            {
                Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter();

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.EmitContextStart();
                pft.Parse();

                int iFoundNTablesWhereN = 0;
                int iObjectCount = writerOut.FileCollectionSize();
                for (int iIndex = 0; iIndex < iObjectCount; ++iIndex)
                {
                    DocElement des = writerOut.ReadBackElementFromFileCollection(iIndex);
                    if (des == null)
                        continue;
                    if (des.GetType() == typeof(Table))
                        ++iFoundNTablesWhereN;
                }
                Assert.IsTrue(iFoundNTablesWhereN == 1);

                int iReadBackIndex = 1;
                DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex);
                Assert.IsTrue(de.GetType() == typeof(Table)); 
// Only returns a table start indicator - proper readback requires the Reader class
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:32,代码来源:TestReadbackFCSObjectsFromRTFFileCollection.cs

示例12: TestColours

        public void TestColours()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentWithCharacterColourProperties.xml", FileMode.Open))
            {
                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null);

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();
                context.ParsingBody = true;

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                List<DocElement> elemsRead = writerOut.Elements;

                int iIndex = 1;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                CharacterProperties charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsNull(charProps);

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps.Color.RGBColor == "FF0000");
                Assert.IsTrue(charProps.FontHighlight == null);

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsNull(charProps);

                iIndex += 3;
           //     Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
             //   Assert.IsTrue(charProps.Color != null);
               // Assert.IsTrue(charProps.Color.ThemeName == "text1");

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsNull(charProps);
                
                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps.Color.RGBColor == "FF0000");
                Assert.IsTrue(charProps.FontHighlight == "green");

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps.Color.RGBColor == "FF0000");
                Assert.IsTrue(charProps.FontHighlight == "green");

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps.Color.RGBColor == "FF0000");
                Assert.IsTrue(charProps.FontHighlight == "green");

                iIndex += 3;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[iIndex].Type);
                charProps = (elemsRead[iIndex] as CharacterFormatting).Properties;
                Assert.IsNull(charProps);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:64,代码来源:TestCharacterProperties.cs

示例13: TestHandleRAndPNodes_simple

        public void TestHandleRAndPNodes_simple()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "RAndPhandlersTest1.xml", FileMode.Open))
            {
                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();

                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(context);
                writerOut.ElementAdded += new EventHandler<TestWriterCallbackInfo>(TestHandleRAndPNodes_simple_OnAddElement);

                context.ParsingBody = true;

                BodyConsumer theBody = new BodyConsumer(context);
                Parser put = new Parser(sIn, theBody, writerOut);

                put.Parse();
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:18,代码来源:TestDocumentContext.cs

示例14: TestVariousCharacterProperties_2

        public void TestVariousCharacterProperties_2()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "Test Additional Character Properties 2 Document.xml", FileMode.Open))
            {
                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null);

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                List<DocElement> elemsRead = writerOut.Elements;

                int index = 1;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                CharacterProperties charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.SmallCaps, "Expected smallcaps");

                index = 7;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.AllCaps, "Expected AllCaps");

            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:TestCharacterProperties.cs

示例15: TestVariousCharacterProperties

        public void TestVariousCharacterProperties()
        {
            using (Stream sIn = new FileStream(TESTFILE_DIR + "Test Additional Character Properties Document.xml", FileMode.Open))
            {
                DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null);

                ParsingContext context = new ParsingContext();
                context.SetDefaultStartContext();

                Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut);
                pft.Parse();
                List<DocElement> elemsRead = writerOut.Elements;

                int index = 4;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                CharacterProperties charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.StrikeThrough, "Expected strikethrough");

                index = 10;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.DoubleStrikeThrough, "Expected double strikethrough");

                index = 16;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Superscript, "Expected superscript");

                index = 22;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Subscript, "Expected subscript");

                index = 28;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Shadow, "Expected shadow");

                index = 34;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Outline, "Expected outline");

                index = 40;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Emboss, "Expected emboss");

                index = 46;
                Assert.AreEqual(DocElementTypes.WPcharacterFormatting, elemsRead[index].Type);
                charProps1 = (elemsRead[index] as CharacterFormatting).Properties;
                Assert.IsTrue(charProps1.Engrave, "Expected engrave");
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:54,代码来源:TestCharacterProperties.cs


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