Example #1
0
        private bool TryFetchFavoritePublicFolder(object[] row, int folderTreeDataSectionValue, out IFavoritePublicFolder favoritePublicFolder, out bool shouldContinue)
        {
            favoritePublicFolder = null;
            shouldContinue       = true;
            StoreId storeId = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <StoreId>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Id);

            if (storeId == null)
            {
                FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: detected item with null id");
                return(false);
            }
            FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: processing item '{0}'", storeId.ToBase64String());
            string text = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.ItemClass);

            if (!ObjectClass.IsFolderTreeData(text))
            {
                shouldContinue = false;
                FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected item class '{0}', stopping enumeration", text);
                return(false);
            }
            int num = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.GroupSection);

            if (folderTreeDataSectionValue != num)
            {
                FavoritePublicFoldersManager.Tracer.TraceDebug <int, int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected group section (expected '{0}', actual '{1}'), skipping", folderTreeDataSectionValue, num);
                return(false);
            }
            int num2 = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Type);

            if (num2 != 0 && num2 != 2 && num2 != 1)
            {
                FavoritePublicFoldersManager.Tracer.TraceDebug <int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected folder type '{0}', skipping", num2);
                return(false);
            }
            byte[] array = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <byte[]>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.NodeEntryId);
            if (array == null)
            {
                FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderEntryId was null");
                return(false);
            }
            StoreObjectId storeObjectId = null;

            try
            {
                storeObjectId = StoreObjectId.FromProviderSpecificId(array);
                if (!storeObjectId.IsPublicFolderType())
                {
                    FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderStoreObjectId is not of the expected type (actual '{0}'), skipping", (storeObjectId == null) ? "null" : storeObjectId.ToHexEntryId());
                    return(false);
                }
                storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId);
            }
            catch (CorruptDataException arg)
            {
                FavoritePublicFoldersManager.Tracer.TraceError <CorruptDataException, string>((long)this.GetHashCode(), "GetFavorites: Exception {0} encountered trying to retrieve navigation node entry ID for folder entry id {1}", arg, (array == null) ? "null" : Convert.ToBase64String(array));
                return(false);
            }
            string displayName = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Subject);

            favoritePublicFolder = new FavoritePublicFolder(storeObjectId, displayName);
            return(true);
        }