Ejemplo n.º 1
0
        public async Task Save(IEnumerable <LibraryItem> libraryItems, bool write, bool report, params string[] names)
        {
            using (var task = new WriteLibraryMetaDataTask(libraryItems, write, names))
            {
                task.InitializeComponent(this.Core);
                await this.OnBackgroundTask(task).ConfigureAwait(false);

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

                if (report && task.Errors.Any())
                {
                    this.OnReport(libraryItems, task.Errors);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task Save(IEnumerable <IFileData> fileDatas, bool write, bool report, params string[] names)
        {
            var libraryItems  = fileDatas.OfType <LibraryItem>().ToArray();
            var playlistItems = fileDatas.OfType <PlaylistItem>().ToArray();

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

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

                    if (report && task.Errors.Any())
                    {
                        this.OnReport(libraryItems, task.Errors);
                    }
                }
            }
            if (playlistItems.Any())
            {
                using (var task = new WritePlaylistMetaDataTask(playlistItems, names, write))
                {
                    task.InitializeComponent(this.Core);
                    await this.OnBackgroundTask(task).ConfigureAwait(false);

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

                    if (report && task.Errors.Any())
                    {
                        this.OnReport(playlistItems, task.Errors);
                    }
                }
            }
        }