本文整理汇总了C#中Header.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# Header.AppendChild方法的具体用法?C# Header.AppendChild怎么用?C# Header.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header.AppendChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHeader
public static string CreateHeader(MainDocumentPart mainPart, OpenXmlCompositeElement element)
{
HeaderPart headerPart = mainPart.AddNewPart<HeaderPart>();
Header header = new Header();
AddHeaderFooterNamespaceDeclaration(header);
if (element != null)
header.AppendChild(element);
headerPart.Header = header;
return mainPart.GetIdOfPart(headerPart);
}
示例2: TestSimpleGroup
//.........这里部分代码省略.........
// </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);
Assert.Equal(1, actual.Errors.Count);
Assert.Same(expected, actual.Errors[0].Node);
Assert.Same(errorChild, actual.Errors[0].RelatedNode);
Assert.Equal(ValidationErrorType.Schema, actual.Errors[0].ErrorType);
Assert.Equal("Sch_InvalidElementContentExpectingComplex", actual.Errors[0].Id);
Assert.True(actual.Errors[0].Description.Contains(":altChunk"));
Assert.True(actual.Errors[0].Description.Contains(":tbl"));
header.RemoveChild(errorChild);
actual.Clear();
//last is invalid
errorChild = header.AppendChild(new Run());
target.Validate(validationContext);
Assert.False(actual.Valid);
Assert.Equal(1, actual.Errors.Count);
Assert.Same(expected, actual.Errors[0].Node);
Assert.Same(errorChild, actual.Errors[0].RelatedNode);
Assert.Equal(ValidationErrorType.Schema, actual.Errors[0].ErrorType);
Assert.Equal("Sch_InvalidElementContentExpectingComplex", actual.Errors[0].Id);
Assert.True(actual.Errors[0].Description.Contains(":altChunk"));
Assert.True(actual.Errors[0].Description.Contains(":tbl"));
header.RemoveChild(errorChild);
}