Beispiel #1
0
        /// <summary>
        ///     Compares two <see cref="IShellItem" />s. The comparison is carried
        ///     out by display order.
        /// </summary>
        /// <param name="item">
        ///     The item to compare.
        /// </param>
        /// <returns>
        ///     0 if the two items are equal. A negative number if
        ///     <see langword="this" /> is before <paramref name="item" /> in
        ///     display order. A positive number if
        ///     <see langword="this" /> comes after <paramref name="item" /> in
        ///     display order.
        /// </returns>
        public int Compare(ShellItem item)
        {
            var result = ComInterface.Compare(item.ComInterface,
                                              SICHINT.DISPLAY);

            return(result);
        }
Beispiel #2
0
        /// <summary>
        ///     Determines whether two <see cref="ShellItem" />s refer to
        ///     the same shell folder.
        /// </summary>
        /// <param name="obj">
        ///     The item to compare.
        /// </param>
        /// <returns>
        ///     <see langword="true" /> if the two objects refer to the same
        ///     folder, <see langword="false" /> otherwise.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj is ShellItem)
            {
                var otherItem = (ShellItem)obj;
                var result    = ComInterface.Compare(otherItem.ComInterface,
                                                     SICHINT.DISPLAY) == 0;

                // Sometimes, folders are reported as being unequal even when
                // they refer to the same folder, so double check by comparing
                // the file system paths. (This was showing up on Windows XP in
                // the SpecialFolders() test)
                if (!result)
                {
                    result = IsFileSystem && otherItem.IsFileSystem &&
                             (FileSystemPath == otherItem.FileSystemPath);
                }

                return(result);
            }
            return(false);
        }