Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonSerializer"></param>
        /// <param name="sessionManager"> </param>
        /// <param name="userDataManager"></param>
        /// <param name="libraryManager"> </param>
        /// <param name="logger"></param>
        /// <param name="httpClient"></param>
        /// <param name="appHost"></param>
        /// <param name="fileSystem"></param>
        public ServerMediator(IJsonSerializer jsonSerializer, ISessionManager sessionManager, IUserDataManager userDataManager, ILibraryManager libraryManager, ILogManager logger, IHttpClient httpClient, IServerApplicationHost appHost, IFileSystem fileSystem)
        {
            Instance = this;
            _sessionManager = sessionManager;
            _libraryManager = libraryManager;
            _logger = logger.GetLogger("Trakt");

            _traktApi = new TraktApi(jsonSerializer, _logger, httpClient, appHost, userDataManager, fileSystem);
            _service = new TraktUriService(_traktApi, _logger, _libraryManager);
            _libraryManagerEventsHelper = new LibraryManagerEventsHelper(_logger, _traktApi);
            _userDataManagerEventsHelper = new UserDataManagerEventsHelper(_logger, _traktApi);

            userDataManager.UserDataSaved += _userDataManager_UserDataSaved;
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonSerializer"></param>
        /// <param name="sessionManager"> </param>
        /// <param name="userDataManager"></param>
        /// <param name="libraryManager"> </param>
        /// <param name="logger"></param>
        /// <param name="httpClient"></param>
        /// <param name="fileSystem"></param>
        public ServerMediator(IJsonSerializer jsonSerializer, ISessionManager sessionManager, IUserDataManager userDataManager,
            ILibraryManager libraryManager, ILogManager logger, IHttpClient httpClient, IFileSystem fileSystem)
        {
            Instance = this;
            _sessionManager = sessionManager;
            _userDataManager = userDataManager;
            _libraryManager = libraryManager;
            _logger = logger.GetLogger("Trakt");
            _fileSystem = fileSystem;

            _traktApi = new TraktApi(jsonSerializer, _logger, httpClient);
            _service = new TraktUriService(_traktApi, _logger, _libraryManager);
            _libraryManagerEventsHelper = new LibraryManagerEventsHelper(_logger, _fileSystem, _traktApi);
            _progressEvents = new List<ProgressEvent>();
            _userDataManagerEventsHelper = new UserDataManagerEventsHelper(_logger, _traktApi);

            // TODO This should probably be elsewhere.
            UpdateUserRatingFormat();

            EnableUserDataSavedEventListener();
        }
        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            _sessionManager.PlaybackStart -= KernelPlaybackStart;
            _sessionManager.PlaybackStopped -= KernelPlaybackStopped;
            _libraryManager.ItemAdded -= LibraryManagerItemAdded;
            _libraryManager.ItemRemoved -= LibraryManagerItemRemoved;
            _service = null;
            _traktApi = null;
            _libraryManagerEventsHelper = null;
            _progressEvents = null;

        }