internal virtual bool Deserialize(XmlReader reader, object parent, PatchStore patchStore) { if (!reader.IsStartElement() || string.CompareOrdinal(reader.LocalName, this.tagName) != 0) { return(false); } bool expectEndElement = !reader.IsEmptyElement; if (!DeserializeAttributes(reader, parent, patchStore)) { return(false); } reader.ReadStartElement(); if (!DeserializeChildren(reader, parent, patchStore)) { return(false); } if (expectEndElement) { reader.ReadEndElement(); } return(true); }
public static bool Deserialize(INode root) { string childrenXml; ApplicationManager.Application.GetHierarchy( null, Microsoft.Office.Interop.OneNote.HierarchyScope.hsChildren, out childrenXml); Debug.Assert(!string.IsNullOrEmpty(childrenXml)); var textReader = new StringReader(childrenXml); var xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreWhitespace = true; xmlReaderSettings.IgnoreProcessingInstructions = true; XmlReader xmlReader = XmlReader.Create(textReader, xmlReaderSettings); var patchStore = new PatchStore(); if (!NotebooksFormatter.Instance.Deserialize(xmlReader, root, patchStore)) { Debug.Assert(false, "unexpected root content"); return(false); } patchStore.PerformPatchOperations(root); return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { while (OEChildrenFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore)) { ; } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { // Big TODO: As Omer pointed out, the content is actually HTML (or presumably a subset // thereof). ((OutlineElement)parent).SetText(ReplaceCharacterEntityReferences(reader.ReadContentAsString())); return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { if (!OEFormatter.Instance.Deserialize(reader, deserializedObject, patchStore)) { throw new Exception("Title element missing OE"); } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { ((Table)parent).AddRow(); while (TableCellFormatter.Instance.Deserialize(reader, parent, patchStore)) { ; } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { // ignore content for now while (reader.IsStartElement()) { reader.Skip(); } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { int columnCount = 0; while (TableColumnFormatter.Instance.Deserialize(reader, parent, patchStore)) { ++columnCount; } ((Table)parent).ColumnCount = columnCount; return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { bool parsedAtLeastOneNotebook = false; while (NotebookEntryFormatter.Instance.Deserialize(reader, parent, patchStore)) { parsedAtLeastOneNotebook = true; } Debug.Assert(parsedAtLeastOneNotebook); return(true); }
internal override bool Deserialize(XmlReader reader, object parent, PatchStore patchStore) { if (!reader.IsStartElement() || string.CompareOrdinal(reader.LocalName, this.tagName) != 0) { return(false); } // ignore MediaFile elements for now reader.Skip(); return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { if (!IndentFormatter.Instance.Deserialize(reader, parent, patchStore)) { throw new Exception("expecting at least one Indent element"); } while (IndentFormatter.Instance.Deserialize(reader, parent, patchStore)) { ; } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { if (!( BulletListItemFormatter.Instance.Deserialize(reader, parent, patchStore) || NumberedListItemFormatter.Instance.Deserialize(reader, parent, patchStore) )) { throw new Exception("unexpected List child " + reader.LocalName); } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { if (AutomaticFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore)) { return(true); } else if (/* TODO: Orientation, Dimensions, Margins*/ false) { return(true); } return(false); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { while (reader.IsStartElement()) { if (!( OEFormatter.Instance.Deserialize(reader, parent, patchStore) )) { throw new Exception("unexpected OEChildren child element " + reader.LocalName); } } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { while (reader.IsStartElement()) { if (!( PositionFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || SizeFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || IndentsFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || OEChildrenFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) )) { throw new Exception("unexpected Outline child " + reader.LocalName); } } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { while (reader.IsStartElement()) { if (!( QuickStyleFormatter.Instance.Deserialize(reader, parent, patchStore) || TagDefFormatter.Instance.Deserialize(reader, parent, patchStore) || MediaPlaylistFormatter.Instance.Deserialize(reader, parent, patchStore) || PageSettingsFormatter.Instance.Deserialize(reader, parent, patchStore) || TitleFormatter.Instance.Deserialize(reader, parent, patchStore) || OutlineFormatter.Instance.Deserialize(reader, parent, patchStore) || InkDrawingFormatter.Instance.Deserialize(reader, parent, patchStore) )) { throw new Exception("unexpected Page child " + reader.LocalName); } } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object obj, PatchStore patchStore) { while (reader.IsStartElement()) { if (!( TextFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || ListFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || TagFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || TableFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || MediaFileFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || ImageFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || InkParagraphFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || InkWordFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) || OEChildrenFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore) )) { throw new Exception("unexpected OE child " + reader.LocalName); } } return(true); }
protected override bool DeserializeChildren(XmlReader reader, object parent, PatchStore patchStore) { bool columnsParsed = false; int rowCount = 0; while (reader.IsStartElement()) { if (!columnsParsed && TableColumnsFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore)) { columnsParsed = true; continue; } if (TableRowFormatter.Instance.Deserialize(reader, this.deserializedObject, patchStore)) { ++rowCount; } } this.deserializedObject.RowCount = rowCount; return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; this.deserializedObject = new PageSettings(parentNode.Depth + 1, parentNode); parentNode.Children.Add(this.deserializedObject); string rtlString = reader.GetAttribute(RtlAttributeName); if (!string.IsNullOrEmpty(rtlString)) { this.deserializedObject.Rtl = bool.Parse(rtlString); } string color = reader.GetAttribute(ColorAttributeName); if (!string.IsNullOrEmpty(color)) { this.deserializedObject.Color = color; } return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { ((PageSize)parent).IsAutomatic = true; return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { // TODO: read attributes ((OutlineElement)parent).ListItem = new BulletListItem(); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; string id = reader.GetAttribute(ObjectIDAttributeName); string author = reader.GetAttribute(AuthorAttributeName); string authorInitials = reader.GetAttribute(AuthorInitialsAttributeName); // DateTime creationTime = DateTime.Parse(reader.GetAttribute("creationTime")); DateTime lastModifiedTime = DateTime.Parse(reader.GetAttribute(LastModifiedTimeAttributeName)); this.deserializedObject = new Outline( parentNode.Depth + 1, parentNode, id, author, authorInitials, lastModifiedTime, // What constitutes the creationTime? lastModifiedTime); string lastModifiedBy = reader.GetAttribute(LastModifiedByAttributeName); if (!string.IsNullOrEmpty(lastModifiedBy)) { this.deserializedObject.LastModifiedBy = lastModifiedBy; } string lastModifiedByInitials = reader.GetAttribute(LastModifiedByInitialsAttributeName); if (!string.IsNullOrEmpty(lastModifiedByInitials)) { this.deserializedObject.LastModifiedByInitials = lastModifiedByInitials; } parentNode.Children.Add(this.deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; string id = reader.GetAttribute(ObjectIdAttributeName); string author = reader.GetAttribute(AuthorAttributeName); string authorInitials = reader.GetAttribute(AuthorInitialsAttributeName); DateTime creationTime = DateTime.Parse(reader.GetAttribute(CreationTimeAttributeName)); DateTime lastModifiedTime = DateTime.Parse(reader.GetAttribute(LastModifiedTimeAttributeName)); string alignment = reader.GetAttribute(AlignmentAttributeName); this.deserializedObject = new OutlineElement( parentNode.Depth + 1, parentNode, id, author, authorInitials, creationTime, lastModifiedTime, alignment); string lastModifiedBy = reader.GetAttribute(LastModifiedByAttributeName); if (!string.IsNullOrEmpty(lastModifiedBy)) { this.deserializedObject.LastModifiedBy = lastModifiedBy; } string lastModifiedByInitials = reader.GetAttribute(LastModifiedByInitialsAttributeName); if (!string.IsNullOrEmpty(lastModifiedByInitials)) { this.deserializedObject.LastModifiedByInitials = lastModifiedByInitials; } string quickStyleIndexStr = reader.GetAttribute("quickStyleIndex"); if (!string.IsNullOrEmpty(quickStyleIndexStr)) { this.deserializedObject.QuickStyleIndex = int.Parse(quickStyleIndexStr); } parentNode.Children.Add(this.deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var deserializedObject = (IPositionedObject)parent; Position position = new Position(); string xStr = reader.GetAttribute(XAttributeName); if (!string.IsNullOrEmpty(xStr)) { position.X = double.Parse(xStr); } string yStr = reader.GetAttribute(YAttributeName); if (!string.IsNullOrEmpty(xStr)) { position.Y = double.Parse(yStr); } string zStr = reader.GetAttribute(ZAttributeName); if (!string.IsNullOrEmpty(zStr)) { position.Z = uint.Parse(zStr); } deserializedObject.Position = position; return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; // required attribute bool isVisible = bool.Parse(reader.GetAttribute(VisibleAttributeName)); this.deserializedObject = new RuleLines(isVisible, parentNode.Depth + 1, parentNode); parentNode.Children.Add(deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; string id = reader.GetAttribute("objectID"); string author = reader.GetAttribute("author"); string authorInitials = reader.GetAttribute("authorInitials"); string creationTimeAttribute = reader.GetAttribute("creationTime"); DateTime creationTime = creationTimeAttribute != null? DateTime.Parse(creationTimeAttribute) : new DateTime(); DateTime lastModifiedTime = DateTime.Parse(reader.GetAttribute("lastModifiedTime")); string shadingColor = reader.GetAttribute("shadingColor"); this.deserializedObject = new TableCell( parentNode.Depth + 1, parentNode, id, author, authorInitials, creationTime, lastModifiedTime, shadingColor); ((Table)parent).AddCell(this.deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; this.deserializedObject = new PageSize(parentNode.Depth + 1, parentNode); parentNode.Children.Add(this.deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; string id = reader.GetAttribute("objectID"); // TODO: Check schema. Examples don't have this attribute. string creationTimeAttribute = reader.GetAttribute("creationTime"); DateTime creationTime = creationTimeAttribute != null? DateTime.Parse(creationTimeAttribute) : new DateTime(); DateTime lastModifiedTime = DateTime.Parse(reader.GetAttribute("lastModifiedTime")); bool bordersAreVisible = bool.Parse(reader.GetAttribute("bordersVisible")); bool hasHeaderRow = bool.Parse(reader.GetAttribute("hasHeaderRow")); this.deserializedObject = new Table( parentNode.Depth + 1, parentNode, id, author: null, // TODO: Check schema authorInitials: null, // TODO: Check schema creationTime, lastModifiedTime, bordersAreVisible, hasHeaderRow); parentNode.Children.Add(this.deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var parentNode = (INode)parent; this.deserializedObject = new Title(parentNode.Depth + 1, parentNode); string language = reader.GetAttribute(LanguageAttributeName); if (!string.IsNullOrEmpty(language)) { this.deserializedObject.Language = language; } parentNode.Children.Add(deserializedObject); return(true); }
protected override bool DeserializeAttributes(XmlReader reader, object parent, PatchStore patchStore) { var deserializedObject = (IOutline)parent; Indent indent = new Indent(); string indentStr = reader.GetAttribute(IndentAttributeName); if (!string.IsNullOrEmpty(indentStr)) { indent.Indentation = double.Parse(indentStr); } string levelStr = reader.GetAttribute(LevelAttributeName); if (!string.IsNullOrEmpty(levelStr)) { indent.Level = uint.Parse(levelStr); } deserializedObject.Indents.Add(indent); return(true); }