public OXmlParagraphElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options) { OXmlParagraphElement paragraph = new OXmlParagraphElement(); while (true) { BsonType bsonType = bsonReader.ReadBsonType(); if (bsonType == BsonType.EndOfDocument) break; //if (bsonType != BsonType.String) // throw new PBException("error ZStringArray cannot contain value of type {0}", bsonType); //var value = bsonReader.ReadString(); string name = bsonReader.ReadName(); switch (name.ToLower()) { case "type": if (bsonType != BsonType.String) throw new PBException($"wrong type value {bsonType}"); string type = bsonReader.ReadString(); if (type.ToLower() != "paragraph") throw new PBException($"invalid Type {type} when deserialize OXmlParagraphElement"); break; case "style": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.String) throw new PBException($"wrong style value {bsonType}"); paragraph.Style = bsonReader.ReadString(); break; default: throw new PBException($"unknow Paragraph value \"{name}\""); } } return paragraph; }
private void AddParagraph(OXmlParagraphElement element) { Paragraph paragraph = new Paragraph(); if (element != null && element.Style != null) { paragraph.ParagraphProperties = new ParagraphProperties { ParagraphStyleId = new ParagraphStyleId { Val = element.Style } } } ; _paragraph = _element.AppendChild(paragraph); //_run = _paragraph.AppendChild(new Run()); _run = null; }
private void AddParagraph(OXmlParagraphElement element) { Paragraph paragraph = new Paragraph(); if (element != null && element.Style != null) paragraph.ParagraphProperties = new ParagraphProperties { ParagraphStyleId = new ParagraphStyleId { Val = element.Style } }; _paragraph = _element.AppendChild(paragraph); //_run = _paragraph.AppendChild(new Run()); _run = null; }