Beispiel #1
0
        internal static bool MemberValues <T>(T x, T y, MemberSettings settings)
        {
            if (TryGetValueEquals(x, y, settings, out var result))
            {
                return(result);
            }

            Verify.CanEqualByMemberValues(x, y, settings, typeof(EqualBy).Name, settings.EqualByMethodName());
            using (var borrowed = settings.ReferenceHandling == ReferenceHandling.Structural
                                   ? ReferencePairCollection.Borrow()
                                   : null)
            {
                return(MemberValues(x, y, settings, borrowed?.Value));
            }
        }
Beispiel #2
0
        internal static void Member <T>(
            T source,
            T target,
            MemberSettings settings,
            MemberInfo member)
            where T : class
        {
            if (settings.IsIgnoringMember(member))
            {
                return;
            }

            using (var borrowed = settings.ReferenceHandling == ReferenceHandling.Structural
                                   ? ReferencePairCollection.Borrow()
                                   : null)
            {
                Member(source, target, settings, borrowed?.Value, member);
            }
        }
Beispiel #3
0
        private static void Sync <T>(T source, T target, MemberSettings settings)
            where T : class
        {
            ////T copy;
            ////if (TryCustomCopy(source, target, settings, out copy))
            ////{
            ////    if (copy != null && !ReferenceEquals(target, copy))
            ////    {
            ////        var message = $"The type {source.GetType()} has custom copy specified. For the root object the copy must be a side effect.\r\n" +
            ////                      $"This means that the custom copy must return null or the target instance.\r\n" +
            ////                      $"Also it makes little sense using this method with custom copy for the root type.";
            ////        throw new InvalidOperationException(message);
            ////    }

            ////    return copy;
            ////}

            using (var borrowed = settings.ReferenceHandling == ReferenceHandling.Structural
                                   ? ReferencePairCollection.Borrow()
                                   : null)
            {
                Sync(source, target, settings, borrowed?.Value);
            }
        }