예제 #1
0
        public async Task <bool> Synchronize(IEnumerable <LibraryItem> libraryItems, params string[] names)
        {
            using (var task = new SynchronizeLibraryMetaDataTask(libraryItems, names))
            {
                task.InitializeComponent(this.Core);
                await this.OnBackgroundTask(task).ConfigureAwait(false);

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

                return(!task.Errors.Any());
            }
        }
예제 #2
0
        public async Task <bool> Synchronize(IEnumerable <IFileData> fileDatas, params string[] names)
        {
            var libraryItems  = fileDatas.OfType <LibraryItem>().ToArray();
            var playlistItems = fileDatas.OfType <PlaylistItem>().ToArray();
            var result        = true;

            if (libraryItems.Any())
            {
                using (var task = new SynchronizeLibraryMetaDataTask(libraryItems, names))
                {
                    task.InitializeComponent(this.Core);
                    await this.OnBackgroundTask(task).ConfigureAwait(false);

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

                    if (task.Errors.Any())
                    {
                        result = false;
                    }
                }
            }
            if (playlistItems.Any())
            {
                using (var task = new SynchronizePlaylistMetaDataTask(playlistItems, names))
                {
                    task.InitializeComponent(this.Core);
                    await this.OnBackgroundTask(task).ConfigureAwait(false);

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

                    if (task.Errors.Any())
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }