The next generation of the Teknik Services. Written in ASP.NET.
https://www.teknik.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
836 B
26 lines
836 B
using System.Collections.Generic; |
|
using System.Dynamic; |
|
|
|
namespace Teknik.Utilities |
|
{ |
|
public static class ObjectHelper |
|
{ |
|
public static dynamic Merge(object item1, object item2) |
|
{ |
|
if (item1 == null || item2 == null) |
|
return item1 ?? item2 ?? new ExpandoObject(); |
|
|
|
dynamic expando = new ExpandoObject(); |
|
var result = expando as IDictionary<string, object>; |
|
foreach (System.Reflection.PropertyInfo fi in item1.GetType().GetProperties()) |
|
{ |
|
result[fi.Name] = fi.GetValue(item1, null); |
|
} |
|
foreach (System.Reflection.PropertyInfo fi in item2.GetType().GetProperties()) |
|
{ |
|
result[fi.Name] = fi.GetValue(item2, null); |
|
} |
|
return result; |
|
} |
|
} |
|
}
|
|
|