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


C# Header.PrependChild方法代码示例

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


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

示例1: TestSimpleGroup

        private void TestSimpleGroup(SdbSchemaDatas sdbSchemaDatas)
        {
            ValidationContext validationContext = new ValidationContext();
            ValidationResult actual = new ValidationResult();
            validationContext.ValidationErrorEventHandler += actual.OnValidationError;
            OpenXmlElement errorChild;

            Header header = new Header();
            var expected = header;
            var particleConstraint = sdbSchemaDatas.GetSchemaTypeData(header).ParticleConstraint;

            // the complex type contains a <xsd:group .../> as child
            var target = particleConstraint.ParticleValidator as GroupParticleValidator;
            validationContext.Element = header;

              //<xsd:complexType name="CT_HdrFtr">
              //  <xsd:group ref="EG_BlockLevelElts" minOccurs="1" maxOccurs="unbounded" />
              //</xsd:complexType>

              //<xs:group name="EG_BlockLevelElts">
              //  <xs:choice>
              //    <xs:group ref="EG_BlockLevelEltsBase" minOccurs="0" maxOccurs="unbounded" />
              //    <xs:group ref="EG_BlockLevelChunkElts" minOccurs="0" maxOccurs="unbounded" />
              //  </xs:choice>
              //</xs:group>

              //<xs:group name="EG_BlockLevelEltsBase">
              //  <xs:choice>
              //    <xs:element name="altChunk" type="CT_AltChunk" minOccurs="0" maxOccurs="unbounded"></xs:element>
              //  </xs:choice>
              //</xs:group>

              //<xsd:group name="EG_BlockLevelChunkElts">
              //  <xsd:choice>
              //    <xsd:group ref="EG_ContentBlockContent" minOccurs="0" maxOccurs="unbounded" />
              //  </xsd:choice>
              //</xsd:group>

              //<xs:group name="EG_ContentBlockContent">
              //  <xs:choice>
              //    <xs:group ref="EG_ContentBlockContentBase" minOccurs="0" maxOccurs="unbounded" />
              //    <xs:group ref="EG_RunLevelElts" minOccurs="0" maxOccurs="unbounded" />
              //  </xs:choice>
              //</xs:group>

              //<xs:group name="EG_ContentBlockContentBase">
              //  <xs:choice>
              //    <xs:element name="customXml" type="CT_CustomXmlBlock"></xs:element>
              //    <xs:element name="sdt" type="CT_SdtBlock"></xs:element>
              //    <xs:element name="p" type="CT_P" minOccurs="0" maxOccurs="unbounded"></xs:element>
              //    <xs:element name="tbl" type="CT_Tbl" minOccurs="0" maxOccurs="unbounded"></xs:element>
              //  </xs:choice>
              //</xs:group>


            // ***** good case ******
            // empty is ok
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // Paragraph is ok
            header.Append(new Paragraph());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // Table is ok
            header.Append(new Table());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // more Paragraph is ok
            header.Append(new Paragraph());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // Sdt is ok
            header.Append(new SdtBlock());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // altChunk is ok
            header.Append(new AltChunk());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // altChunk is ok
            header.Append(new AltChunk());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // more Paragraph is ok
            header.Append(new Paragraph());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // ***** error case ******
            //first is invalid
            errorChild = header.PrependChild(new Run());
            target.Validate(validationContext);
            Assert.False(actual.Valid);
//.........这里部分代码省略.........
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:101,代码来源:GroupParticleValidatorTest.cs


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