switched to yaml as filee format

This commit is contained in:
2020-04-17 22:53:19 +02:00
parent 6cc2470a78
commit 8cb33b89fb
9 changed files with 54 additions and 59 deletions

View File

@ -0,0 +1,20 @@
using System;
using System.Globalization;
namespace ModernWpfPlayground.MvvmStuff
{
public static class DeserializationExtension
{
public static object? Convert(object? value, Type propertyType)
{
if (value is null) return Activator.CreateInstance(propertyType);
if (propertyType.IsEnum && value is string s)
{
return Enum.Parse(propertyType, s);
}
return System.Convert.ChangeType(value, propertyType, CultureInfo.InvariantCulture);
}
}
}