Fix serialization/deserialization tag mappings.
This commit is contained in:
parent
f83c538c94
commit
a6915c32f4
@ -78,9 +78,6 @@
|
|||||||
<Reference Include="System.Xaml" />
|
<Reference Include="System.Xaml" />
|
||||||
<Reference Include="System.XML" />
|
<Reference Include="System.XML" />
|
||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\YamlDotNet.5.2.1\lib\net35\YamlDotNet.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||||
|
@ -3,5 +3,4 @@
|
|||||||
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
||||||
<package id="NLog" version="4.5.11" targetFramework="net40" />
|
<package id="NLog" version="4.5.11" targetFramework="net40" />
|
||||||
<package id="NUnit" version="3.11.0" targetFramework="net40" />
|
<package id="NUnit" version="3.11.0" targetFramework="net40" />
|
||||||
<package id="YamlDotNet" version="5.2.1" targetFramework="net40" />
|
|
||||||
</packages>
|
</packages>
|
@ -18,6 +18,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using zaaReloaded2;
|
||||||
using zaaReloaded2.Formatter;
|
using zaaReloaded2.Formatter;
|
||||||
using zaaReloaded2.Controller.Elements;
|
using zaaReloaded2.Controller.Elements;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -38,33 +39,14 @@ namespace zaaReloaded2.Controller
|
|||||||
public static ISerializer BuildSerializer()
|
public static ISerializer BuildSerializer()
|
||||||
{
|
{
|
||||||
SerializerBuilder builder = new SerializerBuilder()
|
SerializerBuilder builder = new SerializerBuilder()
|
||||||
.WithTagMapping("!Settings", typeof(Settings))
|
.WithCommonTagMappings()
|
||||||
.WithTagMapping("!ElementsList", typeof(List<ElementBase>))
|
|
||||||
.WithTagMapping("!FormatElementsList", typeof(List<FormatElementBase>))
|
|
||||||
.WithTagMapping("!Items", typeof(Items))
|
|
||||||
.WithTagMapping("!CustomText", typeof(CustomText))
|
|
||||||
.WithTagMapping("!SelectFirstDay", typeof(SelectFirstDay))
|
|
||||||
.WithTagMapping("!SelectEachDay", typeof(SelectEachDay))
|
|
||||||
.WithTagMapping("!SelectLastDay", typeof(SelectLastDay))
|
|
||||||
.WithTagMapping("!TwoColumns", typeof(TwoColumns))
|
|
||||||
.WithTagMapping("!NextColumn", typeof(NextColumn))
|
|
||||||
.EnsureRoundtrip();
|
.EnsureRoundtrip();
|
||||||
return builder.Build();
|
return builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDeserializer BuildDeserializer()
|
public static IDeserializer BuildDeserializer()
|
||||||
{
|
{
|
||||||
DeserializerBuilder builder = new DeserializerBuilder()
|
DeserializerBuilder builder = new DeserializerBuilder().WithCommonTagMappings();
|
||||||
.WithTagMapping("!Settings", typeof(Settings))
|
|
||||||
.WithTagMapping("!ElementsList", typeof(List<ElementBase>))
|
|
||||||
.WithTagMapping("!FormatElementsList", typeof(List<FormatElementBase>))
|
|
||||||
.WithTagMapping("!Items", typeof(Items))
|
|
||||||
.WithTagMapping("!CustomText", typeof(CustomText))
|
|
||||||
.WithTagMapping("!SelectFirstDay", typeof(SelectFirstDay))
|
|
||||||
.WithTagMapping("!SelectEachDay", typeof(SelectEachDay))
|
|
||||||
.WithTagMapping("!SelectLastDay", typeof(SelectLastDay))
|
|
||||||
.WithTagMapping("!TwoColumns", typeof(TwoColumns))
|
|
||||||
.WithTagMapping("!NextColumn", typeof(NextColumn));
|
|
||||||
return builder.Build();
|
return builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,11 @@ namespace zaaReloaded2
|
|||||||
private static Lazy<UserSettings> _lazy = new Lazy<UserSettings>(() =>
|
private static Lazy<UserSettings> _lazy = new Lazy<UserSettings>(() =>
|
||||||
{
|
{
|
||||||
// Logger.Info("Initializing singleton instance");
|
// Logger.Info("Initializing singleton instance");
|
||||||
UserSettings s = FromFileOrDefault<UserSettings>(UserSettingsFile);
|
YamlDotNet.Serialization.DeserializerBuilder builder = ConstructDeserializerBuilder<UserSettings>();
|
||||||
|
UserSettings s = FromFileOrDefault<UserSettings>(
|
||||||
|
UserSettingsFile,
|
||||||
|
builder.WithCommonTagMappings()
|
||||||
|
);
|
||||||
Bovender.UserSettings.UserSettingsBase.Default = s;
|
Bovender.UserSettings.UserSettingsBase.Default = s;
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
@ -176,7 +180,7 @@ namespace zaaReloaded2
|
|||||||
|
|
||||||
protected override YamlDotNet.Serialization.SerializerBuilder ConstructSerializerBuilder()
|
protected override YamlDotNet.Serialization.SerializerBuilder ConstructSerializerBuilder()
|
||||||
{
|
{
|
||||||
return base.ConstructSerializerBuilder().EnsureRoundtrip();
|
return new YamlDotNet.Serialization.SerializerBuilder().WithCommonTagMappings().EnsureRoundtrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
28
zaaReloaded2/YamlTagMappingExtension.cs
Executable file
28
zaaReloaded2/YamlTagMappingExtension.cs
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
using zaaReloaded2.Controller;
|
||||||
|
using zaaReloaded2.Controller.Elements;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace zaaReloaded2
|
||||||
|
{
|
||||||
|
static class YamlTagMappingExtension
|
||||||
|
{
|
||||||
|
public static TBuilder WithCommonTagMappings<TBuilder>(this TBuilder builder)
|
||||||
|
where TBuilder : BuilderSkeleton<TBuilder>
|
||||||
|
{
|
||||||
|
return builder
|
||||||
|
.WithTagMapping("!UserSettings", typeof(UserSettings))
|
||||||
|
.WithTagMapping("!Settings", typeof(Settings))
|
||||||
|
.WithTagMapping("!SettingsList", typeof(List<Settings>))
|
||||||
|
.WithTagMapping("!ElementsList", typeof(List<ElementBase>))
|
||||||
|
.WithTagMapping("!FormatElementsList", typeof(List<FormatElementBase>))
|
||||||
|
.WithTagMapping("!Items", typeof(Items))
|
||||||
|
.WithTagMapping("!CustomText", typeof(CustomText))
|
||||||
|
.WithTagMapping("!SelectFirstDay", typeof(SelectFirstDay))
|
||||||
|
.WithTagMapping("!SelectEachDay", typeof(SelectEachDay))
|
||||||
|
.WithTagMapping("!SelectLastDay", typeof(SelectLastDay))
|
||||||
|
.WithTagMapping("!TwoColumns", typeof(TwoColumns))
|
||||||
|
.WithTagMapping("!NextColumn", typeof(NextColumn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,5 +2,4 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
|
||||||
<package id="NLog" version="4.5.11" targetFramework="net40" />
|
<package id="NLog" version="4.5.11" targetFramework="net40" />
|
||||||
<package id="YamlDotNet" version="5.2.1" targetFramework="net40" />
|
|
||||||
</packages>
|
</packages>
|
@ -37,21 +37,21 @@
|
|||||||
<OldToolsVersion>12.0</OldToolsVersion>
|
<OldToolsVersion>12.0</OldToolsVersion>
|
||||||
<VSTO_TrustAssembliesLocation>true</VSTO_TrustAssembliesLocation>
|
<VSTO_TrustAssembliesLocation>true</VSTO_TrustAssembliesLocation>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>false</BootstrapperEnabled>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<InstallUrl />
|
<InstallUrl />
|
||||||
<TargetCulture>en</TargetCulture>
|
<TargetCulture>de</TargetCulture>
|
||||||
<ApplicationVersion>1.0.0.0</ApplicationVersion>
|
<ApplicationVersion>2.5.0.1</ApplicationVersion>
|
||||||
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
|
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
|
||||||
<UpdateEnabled>true</UpdateEnabled>
|
<UpdateEnabled>true</UpdateEnabled>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>1</UpdateInterval>
|
||||||
<UpdateIntervalUnits>days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>days</UpdateIntervalUnits>
|
||||||
<ProductName>zaaReloaded2</ProductName>
|
<ProductName>zaaReloaded2</ProductName>
|
||||||
<PublisherName />
|
<PublisherName>Daniel Kraus</PublisherName>
|
||||||
<SupportUrl />
|
<SupportUrl>https://git.bovender.de/daniel/zaaReloaded2</SupportUrl>
|
||||||
<FriendlyName>zaaReloaded2</FriendlyName>
|
<FriendlyName>zaaReloaded2</FriendlyName>
|
||||||
<OfficeApplicationDescription />
|
<OfficeApplicationDescription>Pimp my Arztbrief</OfficeApplicationDescription>
|
||||||
<LoadBehavior>3</LoadBehavior>
|
<LoadBehavior>16</LoadBehavior>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
@ -202,8 +202,8 @@
|
|||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="YamlDotNet">
|
||||||
<HintPath>..\packages\YamlDotNet.5.2.1\lib\net35\YamlDotNet.dll</HintPath>
|
<HintPath>..\..\YamlDotNet\YamlDotNet\bin\Debug\net40\YamlDotNet.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -339,6 +339,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Updater\Version.cs" />
|
<Compile Include="Updater\Version.cs" />
|
||||||
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
||||||
|
<Compile Include="YamlTagMappingExtension.cs" />
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
@ -375,6 +376,7 @@
|
|||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
<None Include="zaaReloaded2.licenseheader" />
|
<None Include="zaaReloaded2.licenseheader" />
|
||||||
<None Include="zaaReloaded2.pfx" />
|
<None Include="zaaReloaded2.pfx" />
|
||||||
|
<None Include="zaaReloaded2_TemporaryKey.pfx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Defaults\parameters.txt" />
|
<EmbeddedResource Include="Defaults\parameters.txt" />
|
||||||
@ -507,11 +509,10 @@
|
|||||||
<SignManifests>true</SignManifests>
|
<SignManifests>true</SignManifests>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestKeyFile>
|
<ManifestKeyFile>zaaReloaded2_TemporaryKey.pfx</ManifestKeyFile>
|
||||||
</ManifestKeyFile>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestCertificateThumbprint>F20396CB288028D87B0A781625F2E41675ECC16A</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>8994EF923FFA620E49E0985F38504CAA1EDD9969</ManifestCertificateThumbprint>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
@ -528,8 +529,8 @@
|
|||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
||||||
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\16.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="VSTOTemplates" DebugInfoExeName="#Software\Microsoft\Office\16.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/w" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
||||||
<Host Name="Word" GeneratedCodeNamespace="zaaReloaded2" IconIndex="0">
|
<Host Name="Word" GeneratedCodeNamespace="zaaReloaded2" PublishedHash="69C324AB27932AA2FBF2B7EA72250886FF164DE6" IconIndex="0">
|
||||||
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
|
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" PublishedHash="0C530AAEE76F26D28CEC634B01B3D6BC88E00089" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
|
||||||
</Host>
|
</Host>
|
||||||
</FlavorProperties>
|
</FlavorProperties>
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
|
Loading…
Reference in New Issue
Block a user