/// <summary> /// Gets the additional parts. /// </summary> /// <returns>IEnumerable{Video}.</returns> public IEnumerable <Video> GetAdditionalParts() { return(AdditionalPartIds .Select(i => LibraryManager.GetItemById(i)) .Where(i => i != null) .OfType <Video>() .OrderBy(i => i.SortName)); }
/// <summary> /// Refreshes the additional parts. /// </summary> /// <param name="options">The options.</param> /// <param name="fileSystemChildren">The file system children.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{System.Boolean}.</returns> private async Task <bool> RefreshAdditionalParts(MetadataRefreshOptions options, IEnumerable <FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken) { var newItems = LoadAdditionalParts(fileSystemChildren, options.DirectoryService).ToList(); var newItemIds = newItems.Select(i => i.Id).ToList(); var itemsChanged = !AdditionalPartIds.SequenceEqual(newItemIds); var tasks = newItems.Select(i => i.RefreshMetadata(options, cancellationToken)); await Task.WhenAll(tasks).ConfigureAwait(false); AdditionalPartIds = newItemIds; return(itemsChanged); }
/// <summary> /// Refreshes the additional parts. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="forceSave">if set to <c>true</c> [force save].</param> /// <param name="forceRefresh">if set to <c>true</c> [force refresh].</param> /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param> /// <returns>Task{System.Boolean}.</returns> private async Task <bool> RefreshAdditionalParts(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true) { var newItems = LoadAdditionalParts().ToList(); var newItemIds = newItems.Select(i => i.Id).ToList(); var itemsChanged = !AdditionalPartIds.SequenceEqual(newItemIds); var tasks = newItems.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders)); var results = await Task.WhenAll(tasks).ConfigureAwait(false); AdditionalPartIds = newItemIds; return(itemsChanged || results.Contains(true)); }