private FolderHierarchy GetFolderHierarchy(MediaFolder root) { Argument.ThrowIfNull(root, "root"); return new FolderHierarchy(root) {Children = _mediaLibraryService.GetMediaFolders(root.MediaPath).Select(GetFolderHierarchy)}; }
private Models.ImageGallery CreateImageGalleryFromMediaFolder(MediaFolder mediaFolder) { var images = _mediaService.GetMediaFiles(mediaFolder.MediaPath); ImageGallerySettingsRecord imageGallerySettings = GetImageGallerySettings(GetName(mediaFolder.MediaPath)) ?? CreateImageGallerySettings(mediaFolder.MediaPath, ThumbnailDefaultSize, ThumbnailDefaultSize, DefaultKeepAspectRatio, DefaultExpandToFill); return new Models.ImageGallery { Id = imageGallerySettings.Id, LastUpdated = mediaFolder.LastUpdated, MediaPath = mediaFolder.MediaPath, Name = mediaFolder.Name, Size = mediaFolder.Size, User = mediaFolder.User, ThumbnailHeight = imageGallerySettings.ThumbnailHeight, ThumbnailWidth = imageGallerySettings.ThumbnailWidth, Images = images.Select(image => CreateImageFromMediaFile(image, imageGallerySettings)).OrderBy(image => image.Position), KeepAspectRatio = imageGallerySettings.KeepAspectRatio, ExpandToFill = imageGallerySettings.ExpandToFill }; }
private void ImportMediaFolder(MediaFolder mediaFolder, Action<MediaFile> action, CancellationTokenSource cts) { if (cts.IsCancellationRequested) { return; } foreach (var mediaFile in _mediaLibraryService.GetMediaFiles(mediaFolder.MediaPath)) { action(mediaFile); if (cts.IsCancellationRequested) { return; } } // recursive call on sub-folders foreach (var subMediaFolder in _mediaLibraryService.GetMediaFolders(mediaFolder.MediaPath)) { ImportMediaFolder(subMediaFolder, action, cts); } }
public FolderHierarchy(MediaFolder root) { Root = root; Children = new List<FolderHierarchy>(); }