internal static void CopyProperties(RequestMessageBase source, RequestMessageBase target) { Type sourceType = source.GetType(); Type targetType = target.GetType(); foreach (PropertyInfo property in targetType.GetProperties()) { if (property.CanWrite == true) { var sourceProperty = sourceType.GetProperty(property.Name); if (sourceProperty != null) { if (sourceProperty.GetValue(source, null) != null) { property.SetValue(target, sourceProperty.GetValue(source, null), null); } } } } }
internal static void CopyProperties(RequestMessageBase source, RequestMessageBase target) { Type sourceType = source.GetType(); Type targetType = target.GetType(); foreach (PropertyInfo property in targetType.GetProperties()) { if (property.CanWrite == true) { var sourceProperty = sourceType.GetProperty(property.Name); if (sourceProperty != null) { if (sourceProperty.GetValue(source, null) != null) { property.SetValue(target, sourceProperty.GetValue(source, null), null); } } } } }