コード例 #1
0
        private IEnumerable <IMergeOperation <Q> > ProcessTableForTableMemberChanges <Q>(ITable sourceTable, IEnumerable <Q> originalMembers, IEnumerable <Q> refreshedMembers, Func <Q, object> sorter, OperationFactory <Q> factory, IEqualityComparer <Q> comparer) where Q : class, ITableMember <Q>
        {
            var results = new HashSet <IMergeOperation <Q> >();

            // Check for added members
            List <Q> newMembers = originalMembers.Compliment(refreshedMembers).ToList();

            newMembers.ForEach(
                t => results.Add(factory.AdditionOp(sourceTable, t)));

            // Check for removed members
            List <Q> removedMembers = refreshedMembers.Compliment(originalMembers).ToList();

            removedMembers.ForEach(
                t => results.Add(factory.RemovalOp(t)));

            // Check for changed members
            IEnumerable <Q> intersection1 = originalMembers.Intersect(refreshedMembers, comparer).OrderBy(sorter);
            var             x             = refreshedMembers.Intersect(originalMembers, comparer).OrderBy(sorter);
            var             commonItems   = intersection1.Zip(refreshedMembers.Intersect(originalMembers, comparer).OrderBy(sorter));
            string          descriptionOfChanges;

            foreach (var memberPair in commonItems)
            {
                if (memberPair.Key.HasChanges(memberPair.Value, out descriptionOfChanges))
                {
                    results.Add(factory.ChangeOp(memberPair.Key, memberPair.Value, descriptionOfChanges));
                }
            }

            return(results);
        }