Add project files.

This commit is contained in:
Daniel Clark
2022-11-01 15:26:08 +00:00
parent daa7b59f22
commit 7e4f880821
408 changed files with 16863 additions and 0 deletions
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Reflection;
namespace TheXamlGuy.Framework.WPF
{
public static class ObjectExtensions
{
public static T ToObject<T>(this IDictionary<string, object> source) where T : class, new()
{
T? target = new();
if (target.GetType() is { } targetType)
{
foreach (KeyValuePair<string, object> item in source)
{
if (targetType.GetProperty(item.Key) is PropertyInfo propertyInfo)
{
propertyInfo.SetValue(target, item.Value, null);
}
}
}
return target;
}
}
}