예제 #1
0
        /// <summary>
        /// Register all aspects into dependency resolver
        /// </summary>
        /// <returns></returns>
        public IServiceContainer Bootstrap(params Assembly[] scanAssemblies)
        {
            // Proc config validation
            ApplicationConfiguration config = null;

            try
            {
                config = ApplicationConfiguration.Instance;
            }
            catch { }
            finally
            {
                if (config.IsNull())
                {
                    throw new Exception("Signals.Core.Configuration.ApplicationConfiguration is not provided. Please use a configuration provider to provide configuration values!");
                }
            }

            if (DependencyResolver.IsNull() || DependencyResolver().IsNull())
            {
                throw new Exception("Dependency resolver not configured");
            }

            var resolver = DependencyResolver();

            if (!Logging.IsNull() && !Logging().IsNull())
            {
                resolver.Register(typeof(ILogger), Logging());
            }
            if (!Auditing.IsNull() && !Auditing().IsNull())
            {
                resolver.Register(typeof(IAuditProvider), Auditing());
            }
            if (!Cache.IsNull() && !Cache().IsNull())
            {
                resolver.Register(typeof(ICache), Cache());
            }
            if (!Localization.IsNull() && !Localization().IsNull())
            {
                resolver.Register(typeof(ILocalizationProvider), Localization());
            }
            if (!Storage.IsNull() && !Storage().IsNull())
            {
                resolver.Register(typeof(IStorageProvider), Storage());
            }
            if (!MessageChannel.IsNull() && !MessageChannel().IsNull())
            {
                resolver.Register(typeof(IMessageChannel), MessageChannel());
            }
            if (!AuthenticationManager.IsNull() && !AuthenticationManager().IsNull())
            {
                resolver.Register(typeof(IAuthenticationManager), AuthenticationManager());
            }
            if (!AuthorizationManager.IsNull() && !AuthorizationManager().IsNull())
            {
                resolver.Register(typeof(IAuthorizationManager), AuthorizationManager());
            }
            if (!TaskRegistry.IsNull() && !TaskRegistry().IsNull())
            {
                resolver.Register(typeof(ITaskRegistry), TaskRegistry());
            }
            if (!PermissionProvider.IsNull() && !PermissionProvider().IsNull())
            {
                resolver.Register(typeof(IPermissionProvider), PermissionProvider());
            }
            if (!Benchmarker.IsNull() && !Benchmarker().IsNull())
            {
                resolver.Register(typeof(IBenchmarker), Benchmarker());
            }
            if (!PermissionManager.IsNull() && !PermissionManager().IsNull())
            {
                resolver.Register(typeof(IPermissionManager), PermissionManager());
            }

            resolver.Register <CriticalErrorCallbackManager>();
            resolver.Register <IProcessFactory, ProcessFactory>();
            resolver.Register <IProcessExecutor, ProcessExecutor>();

            resolver.Register <IBusinessProcessContext, BusinessProcessContext>();
            resolver.Register <IApiProcessContext, ApiProcessContext>();
            resolver.Register <IDistributedProcessContext, DistributedProcessContext>();
            resolver.Register <IFileExportProcessContext, FileExportProcessContext>();
            resolver.Register <IFileImportProcessContext, FileImportProcessContext>();
            resolver.Register <IRecurringProcessContext, RecurringProcessContext>();

            resolver.Register <Mediator>();

            RegisterProcesses(config, resolver, scanAssemblies);
            RegisterErrorHendling(config, resolver);
            RegisterJsonSerializerSettings(config, resolver);
            RegisterSmtp(config, resolver);
            RegisterSyncLogProvider(config, resolver);

            var services = SystemBootstrapper.Init(resolver, scanAssemblies);

            return(services);
        }