/// <summary> /// Creates a new "drive" representing a connection to OneNote. /// </summary> /// <param name="drive"></param> /// <returns></returns> protected override PSDriveInfo NewDrive(PSDriveInfo drive) { if (drive == null) { WriteError(new ErrorRecord( new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, null)); return(null); } if (String.IsNullOrEmpty(drive.Root)) { WriteError(new ErrorRecord( new ArgumentNullException("drive.Root"), "NoRoot", ErrorCategory.InvalidArgument, null)); return(null); } OneNoteDriveInfo onDriveInfo = new OneNoteDriveInfo(drive); return(onDriveInfo); }
/// <summary> /// Creates a OneNote content reader for a particular onenote instantiation and item in the hierarchy. /// </summary> /// <param name="drive">Can be used to get to the OneNote instantiation.</param> /// <param name="node">The OneNote XML node that identifies the node to "get."</param> public ContentReader(OneNoteDriveInfo drive, XmlNode node) { string id = node.Attributes["ID"].Value; string xml; Microsoft.Office.Interop.OneNote.ApplicationClass _app = new Microsoft.Office.Interop.OneNote.ApplicationClass( ); _app.GetPageContent(id, out xml, Microsoft.Office.Interop.OneNote.PageInfo.piBasic); XmlDocument doc = new XmlDocument( ); doc.LoadXml(xml); _text = Microsoft.Office.OneNote.PowerShell.Utilities.PrettyPrintXml(doc).Split(new char[] { '\n' }); }
/// <summary> /// Creates a new "drive" representing a connection to OneNote. /// </summary> /// <param name="drive"></param> /// <returns></returns> protected override PSDriveInfo NewDrive(PSDriveInfo drive) { if (drive == null) { WriteError(new ErrorRecord( new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, null)); return null; } if (String.IsNullOrEmpty(drive.Root)) { WriteError(new ErrorRecord( new ArgumentNullException("drive.Root"), "NoRoot", ErrorCategory.InvalidArgument, null)); return null; } OneNoteDriveInfo onDriveInfo = new OneNoteDriveInfo(drive); return onDriveInfo; }