本文整理汇总了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);
//.........这里部分代码省略.........