-
Notifications
You must be signed in to change notification settings - Fork 337
Description
I recently came across the need to make layout serialization async.
While this was quite an unpleasent experience, i got it to work....
Not, the reason i created this ticket is the following:
I plan on creating a PR that actually provides that capability to "the masses" and look for advice on what exactly to change.
On my journy to making this async, i found numerous of interfaces encapsulated internal, making the approach i chose for doing things async utilize reflection as the required changes where requiring replacing the event-callback system with a method-callback system (and making everything async down to that point.)
To be more precise, this code:
AvalonDock/source/Components/AvalonDock/Layout/Serialization/LayoutSerializer.cs
Lines 64 to 70 in df288d6
| foreach (var lcToAttach in layout.Descendents().OfType<ILayoutPreviousContainer>().Where(lc => lc.PreviousContainerId != null)) | |
| { | |
| var paneContainerToAttach = layout.Descendents().OfType<ILayoutPaneSerializable>().FirstOrDefault(lps => lps.Id == lcToAttach.PreviousContainerId); | |
| if (paneContainerToAttach == null) | |
| throw new ArgumentException($"Unable to find a pane with id ='{lcToAttach.PreviousContainerId}'"); | |
| lcToAttach.PreviousContainer = paneContainerToAttach as ILayoutContainer; | |
| } |
is a mess right now since all of it requires internally encapsulated stuff:
| internal interface ILayoutPaneSerializable | |
| { | |
| /// <summary>Gets/sets the unique id for this layout pane.</summary> | |
| string Id { get; set; } | |
| } |
AvalonDock/source/Components/AvalonDock/Layout/ILayoutPreviousContainer.cs
Lines 12 to 17 in df288d6
| internal interface ILayoutPreviousContainer | |
| { | |
| ILayoutContainer PreviousContainer { get; set; } | |
| string PreviousContainerId { get; set; } | |
| } |
To come to an end (TL;DR):
- Should i split up that method into multiple parts?
- Make the interfaces public?
- Something else?
Also regarding an async approach, the question is also wether to utilize a single callback method or something else here too?
Thanks for your time,
X39