Exemple #1
0
        /// <summary>
        /// Set the IsPrivate property of all child albums and media objects of the specified album to have the same value
        /// as the specified album.
        /// </summary>
        /// <param name="album">The album whose child objects are to be updated to have the same IsPrivate value.</param>
        private static void SynchIsPrivatePropertyOnChildGalleryObjects(IAlbum album)
        {
            album.Inflate(true);
            foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                childAlbum.Inflate(true);                 // The above Inflate() does not inflate child albums, so we need to explicitly inflate it.
                childAlbum.IsPrivate = album.IsPrivate;
                GalleryObjectController.SaveGalleryObject(childAlbum);
                SynchIsPrivatePropertyOnChildGalleryObjects(childAlbum);
            }

            foreach (IGalleryObject childGalleryObject in album.GetChildGalleryObjects(GalleryObjectType.MediaObject))
            {
                childGalleryObject.IsPrivate = album.IsPrivate;
                GalleryObjectController.SaveGalleryObject(childGalleryObject);
            }
        }
        /// <summary>
        /// Set the IsPrivate property of all child albums and media objects of the specified album to have the same value
        /// as the specified album.
        /// </summary>
        /// <param name="album">The album whose child objects are to be updated to have the same IsPrivate value.</param>
        /// <param name="userName">Name of the current user.</param>
        private static void SynchIsPrivatePropertyOnChildGalleryObjectsRecursive(IAlbum album, string userName)
        {
            album.Inflate(true);
            foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                childAlbum.Inflate(true); // The above Inflate() does not inflate child albums, so we need to explicitly inflate it.
                childAlbum.IsPrivate = album.IsPrivate;
                GalleryObjectController.SaveGalleryObject(childAlbum, userName);
                SynchIsPrivatePropertyOnChildGalleryObjectsRecursive(childAlbum, userName);
            }

            foreach (IGalleryObject childGalleryObject in album.GetChildGalleryObjects(GalleryObjectType.MediaObject))
            {
                childGalleryObject.IsPrivate = album.IsPrivate;
                GalleryObjectController.SaveGalleryObject(childGalleryObject, userName);
            }
        }