This commit is contained in:
parent
d044175e77
commit
f46602d4a4
|
@ -4,13 +4,16 @@
|
|||
{
|
||||
public static void Map<T>(T source, T target) where T : class
|
||||
{
|
||||
foreach (var info in typeof(T).GetProperties())
|
||||
foreach (var info in source.GetType().GetProperties(ReflectionHelper.Flags))
|
||||
{
|
||||
info.SetValue(source, info.GetValue(target));
|
||||
if (info.CanWrite is false) continue;
|
||||
var targetInfo = target.GetType().GetProperty(info.Name, ReflectionHelper.Flags);
|
||||
targetInfo?.SetValue(target, info.GetValue(source));
|
||||
}
|
||||
foreach (var info in typeof(T).GetFields())
|
||||
foreach (var info in source.GetType().GetFields(ReflectionHelper.Flags))
|
||||
{
|
||||
info.SetValue(source, info.GetValue(target));
|
||||
var targetInfo = target.GetType().GetField(info.Name, ReflectionHelper.Flags);
|
||||
targetInfo?.SetValue(target, info.GetValue(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System.Dynamic;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public interface IdComponent
|
||||
{
|
||||
ulong Id { get; set; }
|
||||
}
|
||||
public interface IdComponent_String
|
||||
{
|
||||
string Id { get; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue