public void AddController(ISessionController controller) { var controllers = SessionControllers.ToList(); controllers.Add(controller); SessionControllers = controllers.ToArray(); }
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; }
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; }
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); } } }
/// <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(); } } }
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)); }
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)); }