diff --git a/CHANGELOG.md b/CHANGELOG.md index 719cda7..457b3ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Changed - Updated logo! +- Renamed IOneNoteItemExtensions to OneNoteItemExtensions. - OneNoteNotebook.Notebook returns itself rather than null. - Updated documentation to include examples and more information on the library. - The methods that create hierarchy items e.g. CreatePage, CreateSection, CreateSectionGroup, CreateNotebook now return the ID of the created item. Can be used with the new FindByID. diff --git a/Documentation/articles/samples.md b/Documentation/articles/samples.md index c5e3dd9..caf368e 100644 --- a/Documentation/articles/samples.md +++ b/Documentation/articles/samples.md @@ -4,43 +4,18 @@ The library's original purpose was for the OneNote [Flow Launcher](https://www.f The examples below are not exactly best practices, but they should give you a good starting point! -[//]: # (TODO Fix the LinqPad Link) -They can also be found in [LinqPad]() for easy viewing! (Though be weary of the [Create Page](#create-pages-in-sections-with-less-than-2-pages) example as it will create a pages in your OneNote!) +They can also be found in the free and paid version of [LinqPad](https://www.linqpad.net/) for easy viewing! (Though be weary of the [Create Page](#create-pages-in-sections-with-less-than-2-pages) example as it will create a pages in your OneNote!) ### Get Recent Pages -```csharp -var pages = OneNoteApplication.GetNotebooks() - .GetPages() - .Where(p => !p.IsInRecycleBin) - .OrderByDescending(p => p.LastModified) - .Take(5); - -foreach (var page in pages) -{ - Console.WriteLine(page.Name); -} -``` +[!code-csharp[](../../linqpad-samples/RecentPages.linq#L7-L18)] ### Get All Items in Recycle Bins -```csharp -var items = OneNoteApplication.GetNotebooks() - .Traverse(i => i.IsInRecycleBin()) // use an extension method to check if the item is in the recycle bin - .Where(i => i switch - { - OneNoteSectionGroup sectionGroup when sectionGroup.IsRecycleBin => false, // skip the special recycle bin section group - OneNoteSection section when section.IsDeletedPages => false, // skip the special deleted pages section in a recycle bin - _ => true - }) - .ToList(); +[!code-csharp[](../../linqpad-samples/RecycleBinItems.linq#L7-L26)] +### Search for a Page and Open Its Section -Console.WriteLine(items.Count); -foreach (var item in items) -{ - Console.WriteLine(item.Name); -} -``` +[!code-csharp[](../../linqpad-samples/OpenSection.linq#L7-L17)] ### Create Pages in Sections With Less Than 2 Pages @@ -60,12 +35,6 @@ foreach (var section in sections) } ``` -### Search for a Page and Open Its Section -```csharp -var page = OneNoteApplication.FindPages("This specific search").MaxBy(p => p.LastModified); -OneNoteApplication.OpenInOneNote(page.Section); -``` -### TEST -[!code-csharp[](../../linqpad-samples/RecentPages.linq#L5-L16)] + diff --git a/Odotocodot.OneNote.Linq.Playground/Program.cs b/Odotocodot.OneNote.Linq.Playground/Program.cs index 8b4d769..25114be 100644 --- a/Odotocodot.OneNote.Linq.Playground/Program.cs +++ b/Odotocodot.OneNote.Linq.Playground/Program.cs @@ -3,8 +3,8 @@ public class Program { public static void Main(string[] args) - { - BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).RunAll(); + { + } } } \ No newline at end of file diff --git a/Odotocodot.OneNote.Linq/NuGet.md b/Odotocodot.OneNote.Linq/NuGet.md index 6d045e9..030f782 100644 --- a/Odotocodot.OneNote.Linq/NuGet.md +++ b/Odotocodot.OneNote.Linq/NuGet.md @@ -1,4 +1,3 @@ -![logo](https://github.com/Odotocodot/Linq2OneNote/assets/48138990/bf168880-0bb7-47ac-80dd-e0825a1e021a) # LINQ to OneNote A helper library for dealing with the [OneNote Interop API](https://learn.microsoft.com/en-us/office/client-developer/onenote/application-interface-onenote). diff --git a/linqpad-samples/OpenSection.linq b/linqpad-samples/OpenSection.linq index 8b7cbc3..0494c9d 100644 --- a/linqpad-samples/OpenSection.linq +++ b/linqpad-samples/OpenSection.linq @@ -1,4 +1,17 @@ + + Odotocodot.OneNote.Linq + Odotocodot.OneNote.Linq + false + + using Odotocodot.OneNote.Linq; var page = OneNoteApplication.FindPages("This specific search").MaxBy(p => p.LastModified); -OneNoteApplication.OpenInOneNote(page.Section); \ No newline at end of file +if(page == null) +{ + Console.WriteLine("No page found with that search, try changing it!"); +} +else +{ + OneNoteApplication.OpenInOneNote(page.Section); +} \ No newline at end of file diff --git a/linqpad-samples/RecentPages.linq b/linqpad-samples/RecentPages.linq index a9a01a7..cdce0ad 100644 --- a/linqpad-samples/RecentPages.linq +++ b/linqpad-samples/RecentPages.linq @@ -1,3 +1,9 @@ + + Odotocodot.OneNote.Linq + Odotocodot.OneNote.Linq + false + + using Odotocodot.OneNote.Linq; var pages = OneNoteApplication.GetNotebooks() diff --git a/linqpad-samples/RecycleBinItems.linq b/linqpad-samples/RecycleBinItems.linq index 66c21f8..9d11cbe 100644 --- a/linqpad-samples/RecycleBinItems.linq +++ b/linqpad-samples/RecycleBinItems.linq @@ -1,3 +1,9 @@ + + Odotocodot.OneNote.Linq + Odotocodot.OneNote.Linq + false + + using Odotocodot.OneNote.Linq; var items = OneNoteApplication.GetNotebooks()