Esempio n. 1
0
        public async Task Clear(Playlist playlist)
        {
            var behaviour = default(PlaylistBehaviourBase);

            switch (playlist.Type)
            {
            case PlaylistType.Selection:
                behaviour = ComponentRegistry.Instance.GetComponent <SelectionPlaylistBehaviour>();
                break;

            case PlaylistType.Dynamic:
                behaviour = ComponentRegistry.Instance.GetComponent <DynamicPlaylistBehaviour>();
                break;
            }
            if (behaviour != null)
            {
                await behaviour.Refresh(playlist).ConfigureAwait(false);
            }
            else
            {
                using (var task = new ClearPlaylistTask(playlist))
                {
                    task.InitializeComponent(this.Core);
                    await this.OnBackgroundTask(task).ConfigureAwait(false);

                    await task.Run().ConfigureAwait(false);
                }
            }
        }
Esempio n. 2
0
        protected virtual async Task Refresh(Playlist playlist, string expression, bool force)
        {
            var libraryHierarchy = this.LibraryManager.SelectedHierarchy;

            if (libraryHierarchy == null || LibraryHierarchy.Empty.Equals(libraryHierarchy))
            {
                return;
            }
            var libraryHierarchyNodes = this.LibraryHierarchyBrowser.GetNodes(libraryHierarchy, expression);

            if (!libraryHierarchyNodes.Any())
            {
                Logger.Write(this, LogLevel.Debug, "Library search returned no results: {0}", expression);
                using (var task = new ClearPlaylistTask(playlist))
                {
                    task.InitializeComponent(this.Core);
                    await task.Run().ConfigureAwait(false);
                }
            }
            else
            {
                using (var task = new AddLibraryHierarchyNodesToPlaylistTask(playlist, 0, libraryHierarchyNodes, expression, true, false))
                {
                    task.InitializeComponent(this.Core);
                    await task.Run().ConfigureAwait(false);
                }
            }
        }
Esempio n. 3
0
        public async Task Clear()
        {
            using (var task = new ClearPlaylistTask())
            {
                task.InitializeComponent(this.Core);
                await this.OnBackgroundTask(task).ConfigureAwait(false);

                await task.Run().ConfigureAwait(false);
            }
        }