예제 #1
0
 /// <summary>
 ///     Creates an enumeration of the <see cref="IEnumModifiedClassInfo" /> object.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns>Returns a <see cref="IEnumerable{IModifiedClassInfo}" /> representing the items.</returns>
 public static IEnumerable <IModifiedClassInfo> AsEnumerable(this IEnumModifiedClassInfo source)
 {
     if (source != null)
     {
         source.Reset();
         IModifiedClassInfo mci;
         while ((mci = source.Next()) != null)
         {
             yield return(mci);
         }
     }
 }
예제 #2
0
        /// <summary>
        ///     Gets the differences between the <paramref name="source" /> and <paramref name="target" /> versions.
        /// </summary>
        /// <param name="source">The source (or child) version.</param>
        /// <param name="target">The target (or parent) version.</param>
        /// <param name="filter">The predicate to filter the results.</param>
        /// <param name="predicate">
        ///     The predicate that defines a set of criteria and determines whether the specified differences
        ///     will be loaded.
        /// </param>
        /// <param name="differenceTypes">The type of differences that will be determined.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{String, DifferenceRow}" /> representing the differences for the
        ///     table (or key).
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     target
        ///     or
        ///     differenceTypes
        /// </exception>
        public static Dictionary <string, IEnumerable <DifferenceRow> > GetDifferences(this IVersion source, IVersion target, IQueryFilter filter, Func <string, ITable, bool> predicate, params esriDifferenceType[] differenceTypes)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (differenceTypes == null)
            {
                throw new ArgumentNullException("differenceTypes");
            }

            var list = new Dictionary <string, IEnumerable <DifferenceRow> >();

            IVersionDataChangesInit vdci         = new VersionDataChangesClass();
            IWorkspaceName          wsNameSource = (IWorkspaceName)((IDataset)source).FullName;
            IWorkspaceName          wsNameTarget = (IWorkspaceName)((IDataset)target).FullName;

            vdci.Init(wsNameSource, wsNameTarget);

            IDataChanges           dataChanges = (IDataChanges)vdci;
            IEnumModifiedClassInfo enumMci     = dataChanges.GetModifiedClassesInfo();

            enumMci.Reset();
            IModifiedClassInfo mci;

            while ((mci = enumMci.Next()) != null)
            {
                // The table references are not disposed due to the enumerable return which would result in an RCW exception.
                string tableName   = mci.ChildClassName;
                ITable sourceTable = ((IFeatureWorkspace)source).OpenTable(tableName);
                if (predicate(tableName, sourceTable))
                {
                    IVersionedTable versionedTable = sourceTable as IVersionedTable;
                    ITable          table          = ((IFeatureWorkspace)target).OpenTable(tableName);
                    if (versionedTable != null && table != null)
                    {
                        var rows = versionedTable.GetDifferences(table, filter, differenceTypes);
                        list.Add(tableName, rows);
                    }
                }
            }

            return(list);
        }