Exemplo n.º 1
0
        internal static JToken DifferencesFrom(this IKongEquatable instance, IKongEquatable other)
        {
            var instanceToken = instance.ToDifferenceToken();
            var otherToken    = other.ToDifferenceToken();

            var options = new Options
            {
                ArrayDiff = ArrayDiffMode.Simple,
                TextDiff  = TextDiffMode.Simple
            };

            return(new JsonDiffPatch(options).Diff(otherToken, instanceToken));
        }
Exemplo n.º 2
0
        internal static bool KongEqualsObject <T>(this IKongEquatable <T> instance, object obj) where T : KongObject
        {
            if (obj == null)
            {
                return(false);
            }

            if (ReferenceEquals(instance, obj))
            {
                return(true);
            }

            return(obj is IKongEquatable <T> other && instance.KongEquals(other));
        }
Exemplo n.º 3
0
        internal static bool KongEquals <T>(this IKongEquatable <T> instance, IKongEquatable <T> other) where T : KongObject
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(instance, other))
            {
                return(true);
            }

            if (other.GetType() != instance.GetType())
            {
                return(false);
            }

            var instanceSerialized = instance.GetEqualityValues().ToNormalizedJson();
            var otherSerialized    = other.GetEqualityValues().ToNormalizedJson();

            return(otherSerialized == instanceSerialized);
        }
Exemplo n.º 4
0
 internal static int GetKongHashCode <T>(this IKongEquatable <T> instance) where T : KongObject =>
 instance.GetEqualityValues().ToNormalizedJson().GetHashCode();
Exemplo n.º 5
0
 private static JToken ToDifferenceToken(this IKongEquatable instance) =>
 JToken.FromObject(instance.GetEqualityValues()).Normalize();