예제 #1
0
        public void AddController(ISessionController controller)
        {
            var controllers = SessionControllers.ToList();

            controllers.Add(controller);
            SessionControllers = controllers.ToArray();
        }
예제 #2
0
        public void Dispose()
        {
            _disposed = true;

            StopAutomaticProgress();

            var controllers = SessionControllers.ToList();

            SessionControllers = Array.Empty <ISessionController>();

            foreach (var controller in controllers)
            {
                var disposable = controller as IDisposable;

                if (disposable != null)
                {
                    _logger.LogDebug("Disposing session controller {0}", disposable.GetType().Name);

                    try
                    {
                        disposable.Dispose();
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error disposing session controller");
                    }
                }
            }

            _sessionManager = null;
        }
예제 #3
0
        public void Dispose()
        {
            _disposed = true;

            StopAutomaticProgress();

            var controllers = SessionControllers.ToList();

            SessionControllers = new ISessionController[] { };

            foreach (var controller in controllers)
            {
                var disposable = controller as IDisposable;

                if (disposable != null)
                {
                    _logger.Debug("Disposing session controller {0}", disposable.GetType().Name);

                    try
                    {
                        disposable.Dispose();
                    }
                    catch (Exception ex)
                    {
                        _logger.ErrorException("Error disposing session controller", ex);
                    }
                }
            }

            _sessionManager = null;
        }
예제 #4
0
        public async ValueTask DisposeAsync()
        {
            _disposed = true;

            StopAutomaticProgress();

            var controllers = SessionControllers.ToList();

            foreach (var controller in controllers)
            {
                if (controller is IAsyncDisposable disposableAsync)
                {
                    _logger.LogDebug("Disposing session controller asynchronously {TypeName}", disposableAsync.GetType().Name);
                    await disposableAsync.DisposeAsync().ConfigureAwait(false);
                }
            }
        }
예제 #5
0
        /// <inheritdoc />
        public void Dispose()
        {
            _disposed = true;

            StopAutomaticProgress();

            var controllers = SessionControllers.ToList();

            SessionControllers = Array.Empty <ISessionController>();

            foreach (var controller in controllers)
            {
                if (controller is IDisposable disposable)
                {
                    _logger.LogDebug("Disposing session controller {0}", disposable.GetType().Name);
                    disposable.Dispose();
                }
            }
        }
예제 #6
0
파일: SessionInfo.cs 프로젝트: vadsaaa/Emby
        public Tuple <ISessionController, bool> EnsureController <T>(Func <SessionInfo, ISessionController> factory)
        {
            var controllers = SessionControllers.ToList();

            foreach (var controller in controllers)
            {
                if (controller is T)
                {
                    return(new Tuple <ISessionController, bool>(controller, false));
                }
            }

            var newController = factory(this);

            controllers.Add(newController);

            SessionControllers = controllers.ToArray();
            return(new Tuple <ISessionController, bool>(newController, true));
        }
예제 #7
0
        public Tuple <ISessionController, bool> EnsureController <T>(Func <SessionInfo, ISessionController> factory)
        {
            var controllers = SessionControllers.ToList();

            foreach (var controller in controllers)
            {
                if (controller is T)
                {
                    return(new Tuple <ISessionController, bool>(controller, false));
                }
            }

            var newController = factory(this);

            _logger.LogDebug("Creating new {0}", newController.GetType().Name);
            controllers.Add(newController);

            SessionControllers = controllers.ToArray();
            return(new Tuple <ISessionController, bool>(newController, true));
        }