コード例 #1
0
        public void ConfigureContainer(IUnityContainer container)
        {
            var props = new NotificationProperties();

            Configuration.Bind("Properties", props);
            UnityConfig.Configure(container, props);
        }
コード例 #2
0
 public NotificationSender(
     ICustomerProvider customerProvider,
     IConnectionProvider connectionProvider,
     IIdentityProvider identityProvider,
     IFactoryWatcher factoryWatcher,
     IOptions <NotificationProperties> propsAccessor
     )
 {
     _customerProvider     = customerProvider;
     _connectionProvider   = connectionProvider;
     _identityProvider     = identityProvider;
     _configurationWatcher = factoryWatcher;
     _props = propsAccessor.Value;
 }
コード例 #3
0
        public static IUnityContainer RegisterTypes(IUnityContainer unityContainer, NotificationProperties props)
        {
            //fix Diagnostic extension
            unityContainer.RegisterType <ILoggerFactory, LoggerFactory>(
                new ContainerControlledLifetimeManager(), new InjectionConstructor(new ResolvedParameter <IEnumerable <ILoggerProvider> >())
                );
            unityContainer.AddExtension(new Diagnostic());

            unityContainer.RegisterType <IConnectionProvider, CoreConnectionProvider>();
            unityContainer.RegisterType <ICustomerProvider, CustomerProvider>();
            unityContainer.RegisterType <IIdentityProvider, CoreIdentityProvider>();

            unityContainer.RegisterInstance <ILogger>(new NLogLogger("NLogClient.config"));
            unityContainer.RegisterType <IContentProvider <NotificationChannel>, NotificationChannelProvider>();
            unityContainer.RegisterType <IUserProvider, AlwaysAdminUserProvider>();
            unityContainer.RegisterType <IServiceFactory, ServiceFactory>();
            unityContainer.RegisterFactory <ArticleService>(c => c.Resolve <IServiceFactory>().GetArticleService());
            unityContainer.RegisterType <IContextStorage, QpCachedContextStorage>();
            unityContainer.RegisterType <INotificationChannelService, NotificationChannelService>(new ContainerControlledLifetimeManager());
            unityContainer.RegisterType <INotificationService, NotificationService>();
            unityContainer.RegisterType <IStatusProvider, StatusProvider>();

            unityContainer.RegisterType <IConfigurationService, ConfigurationService>(new ContainerControlledLifetimeManager());
            unityContainer.RegisterType <IMessageService, MessageService>();

            switch (props.SettingsSource)
            {
            case SettingsSource.Content:
                unityContainer.RegisterType <ISettingsService, SettingsFromContentCoreService>();
                break;

            case SettingsSource.AppSettings:
                unityContainer.RegisterType <ISettingsService, SettingsFromQpCoreService>();
                break;
            }

            switch (props.ChannelSource)
            {
            case ChannelSource.Content:
                unityContainer.RegisterType <INotificationProvider, NotificationContentProvider>();
                break;

            case ChannelSource.Configuration:
                unityContainer.RegisterType <INotificationProvider, NotificationConfigurationProvider>();
                break;
            }

            unityContainer.RegisterType <IReadOnlyArticleService, ReadOnlyArticleServiceAdapter>();

            var connection = unityContainer.Resolve <IConnectionProvider>();
            var logger     = unityContainer.Resolve <ILogger>();

            var autoRegister    = true;
            var watcherInterval = TimeSpan.FromMinutes(1);

            if (connection.QPMode)
            {
                unityContainer.AddNewExtension <QPAutopublishContainerConfiguration>();
                unityContainer.RegisterConsolidationCache(autoRegister).With <FactoryWatcher>(watcherInterval).As <IFactoryWatcher>();
            }
            else if (connection.HasConnection(QP.Models.Service.Admin))
            {
                unityContainer.RegisterType <ICustomerProvider, SingleCustomerCoreProvider>();
                unityContainer.RegisterConsolidationCache(autoRegister, SingleCustomerCoreProvider.Key).With <FactoryWatcher>().As <IFactoryWatcher>();
            }
            else
            {
                unityContainer.RegisterType <ICustomerProvider, SingleCustomerCoreProvider>();
                unityContainer.RegisterNullFactory().With <FactoryWatcher>().As <IFactoryWatcher>();
            }

            return(unityContainer);
        }
コード例 #4
0
 public static IUnityContainer Configure(IUnityContainer container, NotificationProperties props)
 {
     container = RegisterTypes(container, props);
     ObjectFactoryConfigurator.DefaultContainer = container;
     return(container);
 }