public static void MergeInto <T>(this T source, T target) { Type type = typeof(T); IEnumerable <FieldInfo> fields = type.GetFields().Where(f => f.GetCustomAttribute <MergeFieldAttribute>() != null); foreach (FieldInfo field in fields) { object value = field.GetValue(source); object targetValue = field.GetValue(target); value = GetLatestVersion(targetValue, value); field.SetValue(target, value); } IEnumerable <PropertyInfo> properties = type.GetProperties().Where(p => p.GetCustomAttribute <MergeFieldAttribute>() != null); foreach (PropertyInfo property in properties) { PropertyAccessor propertyAccessor = PropertyAccessor.Create(property); object value = propertyAccessor.Get(source); object targetValue = propertyAccessor.Get(target); value = GetLatestVersion(targetValue, value); propertyAccessor.Set(target, value); } }