private void ChooseContentDirectory_DialogClosing(object sender, DialogClosingEventArgs eventArgs) { if (Equals(eventArgs.Parameter, false)) { return; } if (!(eventArgs.Parameter is ChooseContentDirectoryViewModel chooseContentDirectoryViewModel)) { return; } string directoryPath = chooseContentDirectoryViewModel.DirectoryPath; if (string.IsNullOrWhiteSpace(directoryPath)) { eventArgs.Cancel(); return; } ContentTypeToFind contentType = chooseContentDirectoryViewModel.SelectedContentType; var parameters = new ContentDirectoryParametersInfo(directoryPath, contentType); _eventAggregator .GetEvent <ProcessContentDirectoryMessage>() .Publish(parameters); }
public ContentDirectoryInfo(string sourceDirectoryPath, ContentTypeToFind contentType, IReadOnlyDictionary <string, IReadOnlyList <string> > data) { data.ThrowIfNull(nameof(data)); SourceDirectoryPath = sourceDirectoryPath.ThrowIfNullOrEmpty(nameof(sourceDirectoryPath)); ContentType = contentType; ContentPaths = TransformToContentModels(data); }
public async Task <ContentDirectoryInfo> GetAllDirectoryContentAsync( string directoryPath, ContentTypeToFind contentType) { directoryPath.ThrowIfNullOrWhiteSpace(nameof(directoryPath)); // TODO: get paging info parameters from View. IReadOnlyDictionary <string, IReadOnlyList <string> > result = await ContentFinder .FindContentForDirWithPagingAsync( directoryName : directoryPath, contentType : contentType.ConvertToLibraryEnum(), pagingInfo : ContentModels.CreateOption(new ContentModels.PagingInfo(0, 10)) ) .ConfigureAwait(continueOnCapturedContext: false); return(new ContentDirectoryInfo(directoryPath, contentType, result)); }
public static ContentModels.ContentType ConvertToLibraryEnum( this ContentTypeToFind contentType) { return(contentType switch { ContentTypeToFind.Movie => ContentModels.ContentType.Movie, ContentTypeToFind.Image => ContentModels.ContentType.Image, ContentTypeToFind.Text => ContentModels.ContentType.Text, _ => throw new ArgumentOutOfRangeException( nameof(contentType), contentType, $"Unknown content type: \"{contentType.ToString()}\"." ) });
public ContentDirectoryParametersInfo(string directoryPath, ContentTypeToFind contentType) { DirectoryPath = directoryPath.ThrowIfNullOrWhiteSpace(nameof(directoryPath)); ContentType = contentType; }