Beispiel #1
0
        /// <summary>
        /// Refresh metadata on us by execution our provider chain
        /// The item will be persisted if a change is made by a provider, or if it's new or changed.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="forceSave">if set to <c>true</c> [is new item].</param>
        /// <param name="forceRefresh">if set to <c>true</c> [force].</param>
        /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
        /// <param name="resetResolveArgs">if set to <c>true</c> [reset resolve args].</param>
        /// <returns>true if a provider reports we changed</returns>
        public override async Task <bool> RefreshMetadata(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true, bool resetResolveArgs = true)
        {
            if (resetResolveArgs)
            {
                ResolveArgs = null;
            }

            var changed = await ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders).ConfigureAwait(false);

            if (changed || forceSave)
            {
                cancellationToken.ThrowIfCancellationRequested();

                await UserManager.UpdateUser(this).ConfigureAwait(false);
            }

            return(changed);
        }
Beispiel #2
0
        /// <summary>
        /// Overrides the base implementation to refresh metadata for local trailers
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="forceSave">if set to <c>true</c> [is new item].</param>
        /// <param name="forceRefresh">if set to <c>true</c> [force].</param>
        /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
        /// <param name="resetResolveArgs">if set to <c>true</c> [reset resolve args].</param>
        /// <returns>true if a provider reports we changed</returns>
        public virtual async Task <bool> RefreshMetadata(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true, bool resetResolveArgs = true)
        {
            if (resetResolveArgs)
            {
                ResolveArgs = null;
            }

            // Lazy load these again
            LocalTrailers = null;

            // Refresh for the item
            var itemRefreshTask = ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);

            cancellationToken.ThrowIfCancellationRequested();

            // Refresh metadata for local trailers
            var trailerTasks = LocalTrailers.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));

            cancellationToken.ThrowIfCancellationRequested();

            // Await the trailer tasks
            await Task.WhenAll(trailerTasks).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            // Get the result from the item task
            var changed = await itemRefreshTask.ConfigureAwait(false);

            if (changed || forceSave)
            {
                cancellationToken.ThrowIfCancellationRequested();

                await Kernel.Instance.ItemRepository.SaveItem(this, cancellationToken).ConfigureAwait(false);
            }

            return(changed);
        }