/// <summary> /// Copies field values from source to target. /// Event fields are excluded /// </summary> /// <typeparam name="T">The type to get ignore fields for settings for</typeparam> /// <param name="source">The instance to copy field values from</param> /// <param name="target">The instance to copy field values to</param> /// <param name="settings">Contains configuration for how to copy</param> public static void FieldValues <T>(T source, T target, FieldsSettings settings) where T : class { Ensure.NotNull(source, nameof(source)); Ensure.NotNull(target, nameof(target)); Ensure.SameType(source, target, nameof(source), nameof(target)); Verify.CanCopyRoot(typeof(T), settings); Sync(source, target, settings); }
/// <summary> /// Check if the properties of <paramref name="type"/> can be copied. /// This method will throw an exception if copy cannot be performed for <paramref name="type"/> /// Read the exception message for detailed instructions about what is wrong. /// Use this to fail fast or in unit tests. /// </summary> /// <param name="type">The type to check</param> /// <param name="settings">Contains configuration for how copy will be performed</param> public static void VerifyCanCopyPropertyValues(Type type, PropertiesSettings settings) { Verify.CanCopyRoot(type, settings); Verify.CanCopyMemberValues(type, settings, typeof(Copy).Name, nameof(VerifyCanCopyPropertyValues)); }
internal static void VerifyCanCopyPropertyValues(Type type, PropertiesSettings settings, string classname, string methodName) { Verify.CanCopyRoot(type, settings); Verify.GetOrCreateErrors(type, settings) .ThrowIfHasErrors(settings, classname, methodName); }
/// <summary> /// Check if the fields of <paramref name="type"/> can be copied. /// This method will throw an exception if copy cannot be performed for <paramref name="type"/> /// Read the exception message for detailed instructions about what is wrong. /// Use this to fail fast or in unit tests. /// </summary> /// <param name="type">The type to get ignore fields for settings for</param> /// <param name="settings">Contains configuration for how copy is performed</param> public static void VerifyCanCopyFieldValues(Type type, FieldsSettings settings) { Verify.CanCopyRoot(type, settings); Verify.CanCopyMemberValues(type, settings, typeof(Copy).Name, nameof(VerifyCanCopyFieldValues)); }