Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced LayoutSerializer with Async variant #265

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
X39 committed Jan 14, 2022
commit af5942908f6a121775b837c92e141931ca8dc356
13 changes: 13 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions source/.idea/.idea.AvalonDock/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/aws.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions source/.idea/.idea.AvalonDock/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions source/AvalonDock.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=anchorable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Anchorables/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This program is provided to you under the terms of the Microsoft Public

using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
Expand All @@ -31,6 +32,23 @@ public AsyncXmlLayoutSerializer(DockingManager manager)

#endregion Constructors


#region Private Methods

/// <summary>Performs all required actions for deserialization.</summary>
/// <param name="function">
/// A function, receiving the <see cref="LayoutRoot"/> <see cref="XmlSerializer"/>,
/// that is supposed to call a deserialize method.
/// </param>
private Task DeserializeCommon(Func<XmlSerializer, LayoutRoot> function)
=> DeserializeCommon(() =>
{
var serializer = XmlSerializer.FromTypes(new[] {typeof(LayoutRoot)}).First();
return function(serializer);
});

#endregion

#region Public Methods

/// <summary>Serialize the layout into a <see cref="XmlWriter"/>.</summary>
Expand Down Expand Up @@ -69,33 +87,18 @@ public void Serialize(string filepath)

/// <summary>Deserialize the layout a file from a <see cref="Stream"/>.</summary>
/// <param name="stream"></param>
public async Task Deserialize(System.IO.Stream stream)
{
var serializer = new XmlSerializer(typeof(LayoutRoot));
var layout = (LayoutRoot)serializer.Deserialize(stream);
await FixupLayout(layout);
Manager.Layout = layout;
}
public Task Deserialize(Stream stream)
=> DeserializeCommon((xmlSerializer) => (LayoutRoot) xmlSerializer.Deserialize(stream));

/// <summary>Deserialize the layout a file from a <see cref="TextReader"/>.</summary>
/// <param name="reader"></param>
public async Task Deserialize(TextReader reader)
{
var serializer = new XmlSerializer(typeof(LayoutRoot));
var layout = (LayoutRoot)serializer.Deserialize(reader);
await FixupLayout(layout);
Manager.Layout = layout;
}
public Task Deserialize(TextReader reader)
=> DeserializeCommon((xmlSerializer) => (LayoutRoot) xmlSerializer.Deserialize(reader));

/// <summary>Deserialize the layout a file from a <see cref="XmlReader"/>.</summary>
/// <param name="reader"></param>
public async Task Deserialize(XmlReader reader)
{
var serializer = new XmlSerializer(typeof(LayoutRoot));
var layout = (LayoutRoot)serializer.Deserialize(reader);
await FixupLayout(layout);
Manager.Layout = layout;
}
public Task Deserialize(XmlReader reader)
=> DeserializeCommon((xmlSerializer) => (LayoutRoot) xmlSerializer.Deserialize(reader));

/// <summary>Deserialize the layout from a file using a <see cref="StreamReader"/>.</summary>
/// <param name="filepath"></param>
Expand Down
Loading