Пример #1
0
        internal static void Sync <T>(T source, T target, MemberSettings settings, ReferencePairCollection referencePairs)
        {
            Debug.Assert(source != null, nameof(source));
            Debug.Assert(target != null, nameof(target));
            Debug.Assert(source.GetType() == target.GetType(), "Must be same type");
            Verify.CanCopyMemberValues(source, target, settings);

            if (referencePairs?.Add(source, target) == false)
            {
                return;
            }

            if (TryCustomCopy(source, target, settings, out var copy))
            {
                return;
            }

            CollectionItems(source, target, settings, referencePairs);
            Members(source, target, settings, referencePairs);
        }
Пример #2
0
 /// <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));
 }
Пример #3
0
 /// <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));
 }