Example #1
0
        private IEnumerable <FieldChange> FindDifferencesOfProperties(TupleBuilder tuple)
        {
            foreach (var currentProperty in tuple.Current.Properties().Where(x => x.Value.Type != JTokenType.Array))
            {
                tuple.BuildProperties(currentProperty);

                var comparer = new TokenComparer();

                if (!comparer.AreEqual(tuple.GetFirstProperty(), tuple.GetSecondProperty()))
                {
                    if (currentProperty.Value is JObject)
                    {
                        tuple.AssignParameters();

                        foreach (var result in FindDifferences(tuple.CreateChildTuple()))
                        {
                            yield return(result);
                        }
                    }
                    else
                    {
                        yield return(new ChangeCreator(tuple).CreateFieldChange());
                    }
                }
            }
        }
Example #2
0
        private IEnumerable <FieldChange> FindDifferencesOfCollections(TupleBuilder tuple)
        {
            foreach (var currentProperty in tuple.Current.Properties().Where(x => x.Value.Type == JTokenType.Array))
            {
                tuple.BuildArrays(currentProperty);

                var comparer = new TokenComparer();

                if (!comparer.ArraysHaveSameNumberOfItems(tuple.GetFirstArray(), tuple.GetSecondArray()))
                {
                    yield return(new ChangeCreator(tuple).CreateFieldChangeFromArray());
                }
                else
                {
                    for (var i = 0; i < tuple.CurrentArray.Count; i++)
                    {
                        tuple.BuildArrayItems(i);

                        if (tuple.CurrentArrayItem is JObject)
                        {
                            tuple.AssignParametersFromArrayItem();

                            foreach (var result in FindDifferences(tuple.CreateChildTuple()))
                            {
                                yield return(result);
                            }
                        }
                        else
                        {
                            if (!comparer.AreEqual(tuple.GetFirstArrayItem(), tuple.GetSecondArrayItem()))
                            {
                                yield return(new ChangeCreator(tuple).CreateFieldChangeFromArrayItem());
                            }
                        }
                    }
                }
            }
        }