示例#1
0
        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");
        }
示例#2
0
        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)));
        }
示例#3
0
        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");
        }
示例#4
0
 protected override void DisposeContainer(IBootstrapperLogger logger, ILifetimeScope container)
 {
     logger.Trace("Disposing IOC container");
     container.Dispose();
     logger.Debug("IOC container disposed");
 }
示例#5
0
        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;
            }
        }