// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see .
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Utils;
namespace Kyoo.Core.Controllers
{
public class LibraryManager : ILibraryManager
{
///
/// The list of repositories
///
private readonly IBaseRepository[] _repositories;
///
public ILibraryRepository LibraryRepository { get; }
///
public ILibraryItemRepository LibraryItemRepository { get; }
///
public ICollectionRepository CollectionRepository { get; }
///
public IShowRepository ShowRepository { get; }
///
public ISeasonRepository SeasonRepository { get; }
///
public IEpisodeRepository EpisodeRepository { get; }
///
public ITrackRepository TrackRepository { get; }
///
public IPeopleRepository PeopleRepository { get; }
///
public IStudioRepository StudioRepository { get; }
///
public IGenreRepository GenreRepository { get; }
///
public IProviderRepository ProviderRepository { get; }
///
public IUserRepository UserRepository { get; }
///
/// Create a new instance with every repository available.
///
/// The list of repositories that this library manager should manage.
/// If a repository for every base type is not available, this instance won't be stable.
public LibraryManager(IEnumerable repositories)
{
_repositories = repositories.ToArray();
LibraryRepository = GetRepository() as ILibraryRepository;
LibraryItemRepository = GetRepository() as ILibraryItemRepository;
CollectionRepository = GetRepository() as ICollectionRepository;
ShowRepository = GetRepository() as IShowRepository;
SeasonRepository = GetRepository() as ISeasonRepository;
EpisodeRepository = GetRepository() as IEpisodeRepository;
TrackRepository = GetRepository