protected override void ComposeContainer(IBootstrapperLogger logger, ILifetimeScope container) { logger.Trace("Initializing view resolver..."); GlobalServices.Register(container.Resolve <IViewResolverService>()); logger.Debug("View resolver initialized successfully"); logger.Trace("Initializing command service..."); container.Resolve <ICommandService>(); logger.Debug("Command service initialized successfully"); }
protected override ILifetimeScope CreateContainer(IBootstrapperLogger logger, ILifetimeScope parentContainer) { logger.Trace("Configuring IOC builder"); if (parentContainer == null) { var builder = new ContainerBuilder(); RegisterContainerTypes(logger, builder); logger.Trace("Building IOC container"); return(builder.Build()); } logger.Trace("Extending parent IOC container with local definitions"); return(parentContainer.BeginDisposableLifetimeScope(builder => RegisterContainerTypes(logger, builder))); }
private void RegisterContainerTypes(IBootstrapperLogger logger, ContainerBuilder builder) { logger.Trace("Registering modules..."); builder.RegisterModule <MainModule>(); builder.RegisterModule <DiagramModule>(); builder.RegisterModule <ControlsModule>(); builder.RegisterModule <NativeControlsModule>(); builder.RegisterModule <RibbonModule>(); logger.Debug("Modules registered"); }
protected override void DisposeContainer(IBootstrapperLogger logger, ILifetimeScope container) { logger.Trace("Disposing IOC container"); container.Dispose(); logger.Debug("IOC container disposed"); }
public void Dispose() { CheckDisposed(); if (_disposing) { return; } try { _disposing = true; _logger.Trace("Application cleanup try"); if (Container == null) { return; } try { _logger.Trace("Application IOC cleaning"); DisposeContainer(_logger, Container); _logger.Debug("Application IOC cleaned successfully"); } catch (Exception e) { var message = "Error on IOC cleaning. Details: " + e.GetBaseException().Message; _logger.Warn(message); } try { _logger.Trace("Application disposing"); Dispose(_logger); _logger.Debug("Application disposed"); } catch (Exception e) { _logger.Warn($"Error on IOC cleaning. Details: {e.GetBaseException().Message}"); } _container = null; } finally { GC.SuppressFinalize(this); _disposing = false; _disposed = true; } }