internal OneNoteEntity GetEntity(string hierarchyXml) { _xmlDoc.LoadXml(hierarchyXml); XmlElement rootNode = _xmlDoc.DocumentElement; OneNoteEntity entity = GetEntity(rootNode); if (string.Compare(rootNode.Name, SectionNodeName, true) == 0) { return(new OneNoteSection(entity.Id, entity.Name)); } else if (string.Compare(rootNode.Name, PageNodeName, true) == 0) { return(new OneNotePage(entity.Id, entity.Name)); } else { throw new ApplicationException(string.Format("Invalid OneNote xml. Unable to create OneNoteEntity. XML: {0}", hierarchyXml)); } }
private void InsertSnipIntoSelectedObject(string oneNoteObjectId) { try { string hierarchyXml; _oneNoteApp.GetHierarchy(oneNoteObjectId, OneNote.HierarchyScope.hsSelf, out hierarchyXml, _oneNoteXmlSchema); OneNoteEntity entity = _oneNoteXml.GetEntity(hierarchyXml); if (entity is OneNoteSection) { InsertImageIntoSection((OneNoteSection)entity, _imageFilePath, _publishUrl); } else if (entity is OneNotePage) { InsertImageIntoPage((OneNotePage)entity, _imageFilePath, _publishUrl); } } catch (Exception ex) { _insertException = ex; // will be reported in InsertSnip() after this fcn returns } }