/// <summary> /// Autofac configuration. /// </summary> public static ContainerBuilder ConfigureContainer( IConfigurationRoot configuration) { var serviceInfo = new ServiceInfo(); var config = new Config(configuration); var builder = new ContainerBuilder(); builder.RegisterInstance(serviceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(config) .AsImplementedInterfaces().SingleInstance(); // register logger builder.RegisterLogger(LogEx.ApplicationInsights(config, configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // Now Monitor model upload notification using ... if (!config.UseFileNotificationHost) { // ... event processor for fan out (requires blob // notification router to be running) ... builder.RegisterType <EventProcessorHost>() .AsImplementedInterfaces(); builder.RegisterType <EventProcessorFactory>() .AsImplementedInterfaces().SingleInstance(); } else { // ... or listen for file notifications on hub directly // (for simplicity) ... builder.RegisterType <IoTHubFileNotificationHost>() .AsImplementedInterfaces(); } // ... then call the injected blob processor to load blob ... builder.RegisterType <BlobStreamProcessor>() .AsImplementedInterfaces(); // ... and pass to either importer which imports the data ... builder.RegisterType <SourceStreamImporter>() .AsImplementedInterfaces(); builder.RegisterType <TaskProcessor>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <JsonVariantEncoder>() .AsImplementedInterfaces().SingleInstance(); // ... into cosmos db collection with configured name. builder.RegisterType <ItemContainerFactory>() .AsImplementedInterfaces(); builder.RegisterType <CosmosDbServiceClient>() .AsImplementedInterfaces(); // ... or ... return(builder); }
/// <summary> /// Autofac configuration. /// </summary> public static ContainerBuilder ConfigureContainer( IConfigurationRoot configuration) { var serviceInfo = new ServiceInfo(); var config = new Config(configuration); var builder = new ContainerBuilder(); builder.RegisterInstance(serviceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(config) .AsImplementedInterfaces().SingleInstance(); // register logger builder.RegisterLogger(LogEx.ApplicationInsights(config, configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); #if DEBUG builder.RegisterType <NoOpCertValidator>() .AsImplementedInterfaces(); #endif // Iot hub services builder.RegisterType <IoTHubMessagingHttpClient>() .AsImplementedInterfaces().SingleInstance(); // Register event bus builder.RegisterType <EventBusHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusClientFactory>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusEventBus>() .AsImplementedInterfaces().SingleInstance(); // ... and event subscriptions builder.RegisterType <ApplicationEventSubscriber>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <EndpointEventSubscriber>() .AsImplementedInterfaces().SingleInstance(); // ... // Register alerters builder.RegisterType <EndpointSecurityAlerter>() .AsImplementedInterfaces(); // ... return(builder); }
/// <summary> /// Autofac configuration. /// </summary> /// <param name="builder"></param> public virtual void ConfigureContainer(ContainerBuilder builder) { // Register service info and configuration interfaces builder.RegisterInstance(ServiceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(Config) .AsImplementedInterfaces().SingleInstance(); // Register logger builder.RegisterLogger(LogEx.ApplicationInsights(Config.Configuration, Config)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // CORS setup builder.RegisterType <CorsSetup>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); // ... with bearer auth if (Config.AuthRequired) { builder.RegisterType <BehalfOfTokenProvider>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DistributedTokenCache>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HttpBearerAuthentication>() .AsImplementedInterfaces().SingleInstance(); } // Iot hub services builder.RegisterType <IoTHubServiceHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubTwinMethodClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ChunkMethodClient>() .AsImplementedInterfaces().SingleInstance(); // Adapters and corresponding edge client builder.RegisterModule <TwinModuleClients>(); builder.RegisterType <HistoricAccessAdapter <string> >() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HistoricAccessAdapter <EndpointRegistrationModel> >() .AsImplementedInterfaces().SingleInstance(); }
/// <summary> /// Autofac configuration. Find more information here: /// </summary> /// <param name="builder"></param> public virtual void ConfigureContainer(ContainerBuilder builder) { // Register service info and configuration interfaces builder.RegisterInstance(ServiceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(Config) .AsImplementedInterfaces().SingleInstance(); // register the serilog logger builder.RegisterLogger(LogEx.ApplicationInsights(Config, Config.Configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // CORS setup builder.RegisterType <CorsSetup>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); // ... with bearer auth builder.RegisterType <DistributedTokenCache>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HttpBearerAuthentication>() .AsImplementedInterfaces().SingleInstance(); // key vault client ... builder.RegisterType <UserOrServiceTokenProvider>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <KeyVaultServiceClient>() .AsImplementedInterfaces().SingleInstance(); // Register event bus ... builder.RegisterType <EventBusHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusClientFactory>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusEventBus>() .AsImplementedInterfaces().SingleInstance(); // ... subscribe to application events ... builder.RegisterType <ApplicationEventSubscriber>() .AsImplementedInterfaces().SingleInstance(); // ... and auto start builder.RegisterType <HostAutoStart>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <RegistryEventHandler>() .AsImplementedInterfaces().SingleInstance(); // Crypto services builder.RegisterType <CertificateDatabase>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <CertificateRevoker>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <CertificateFactory>() .AsImplementedInterfaces().SingleInstance(); // TODO: Add keyvault builder.RegisterType <CertificateIssuer>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <KeyDatabase>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <KeyHandleSerializer>() .AsImplementedInterfaces().SingleInstance(); // Register registry micro services adapters builder.RegisterType <RegistryServiceClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <RegistryAdapter>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <EntityInfoResolver>() .AsImplementedInterfaces().SingleInstance(); // Vault services builder.RegisterType <RequestDatabase>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <GroupDatabase>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <CertificateRequestEventBroker>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <CertificateRequestManager>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <TrustGroupServices>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <CertificateAuthority>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <KeyPairRequestProcessor>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <SigningRequestProcessor>() .AsImplementedInterfaces().SingleInstance(); // Vault handler builder.RegisterType <AutoApproveHandler>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <KeyPairRequestHandler>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <SigningRequestHandler>() .AsImplementedInterfaces().SingleInstance(); // ... with cosmos db collection as storage builder.RegisterType <ItemContainerFactory>() .AsImplementedInterfaces(); builder.RegisterType <CosmosDbServiceClient>() .AsImplementedInterfaces(); }
/// <summary> /// Autofac configuration. /// </summary> /// <param name="builder"></param> public virtual void ConfigureContainer(ContainerBuilder builder) { // Register service info and configuration interfaces builder.RegisterInstance(ServiceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(Config) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(Config.Configuration) .AsImplementedInterfaces().SingleInstance(); // Register logger builder.RegisterLogger(LogEx.ApplicationInsights(Config, Config.Configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // CORS setup builder.RegisterType <CorsSetup>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); // ... with bearer auth if (Config.AuthRequired) { builder.RegisterType <BehalfOfTokenProvider>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DistributedTokenCache>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HttpBearerAuthentication>() .AsImplementedInterfaces().SingleInstance(); } // Iot hub services builder.RegisterType <IoTHubServiceHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubMessagingHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubTwinMethodClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ChunkMethodClient>() .AsImplementedInterfaces().SingleInstance(); // Register event bus for event publishing builder.RegisterType <EventBusHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusClientFactory>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusEventBus>() .AsImplementedInterfaces().SingleInstance(); // Cosmos db collection as storage builder.RegisterType <ItemContainerFactory>() .AsImplementedInterfaces(); builder.RegisterType <CosmosDbServiceClient>() .AsImplementedInterfaces(); // Registries and repositories builder.RegisterModule <RegistryServices>(); builder.RegisterType <StartupMigration>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <VaultApplicationMigration>() .AsImplementedInterfaces().SingleInstance(); #if !USE_APP_DB // TODO: Decide whether when to switch builder.RegisterType <ApplicationTwins>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ApplicationRecordQuery>() .AsImplementedInterfaces().SingleInstance(); #else builder.RegisterType <ApplicationDatabase>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ApplicationTwinsMigration>() .AsImplementedInterfaces().SingleInstance(); #endif // Additional registry services builder.RegisterType <ActivationClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DiagnosticsClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <OnboardingClient>() .AsImplementedInterfaces().SingleInstance(); }
/// <summary> /// Autofac configuration. /// </summary> public static ContainerBuilder ConfigureContainer( IConfigurationRoot configuration) { var serviceInfo = new ServiceInfo(); var config = new Config(configuration); var builder = new ContainerBuilder(); builder.RegisterInstance(serviceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(config) .AsImplementedInterfaces().SingleInstance(); // register logger builder.RegisterLogger(LogEx.ApplicationInsights(config, configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); #if DEBUG builder.RegisterType <NoOpCertValidator>() .AsImplementedInterfaces(); #endif // Iot hub services builder.RegisterType <IoTHubServiceHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubTwinMethodClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ChunkMethodClient>() .AsImplementedInterfaces().SingleInstance(); // Register event bus builder.RegisterType <EventBusHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusClientFactory>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusEventBus>() .AsImplementedInterfaces().SingleInstance(); // Register task processor builder.RegisterType <TaskProcessor>() .AsImplementedInterfaces().SingleInstance(); // Handle discovery request and pass to all edges builder.RegisterType <SupervisorRegistry>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DiscoveryRequestHandler>() .AsImplementedInterfaces().SingleInstance(); #if USE_JOBS builder.RegisterType <DiscoveryJobClient>() .AsImplementedInterfaces().SingleInstance(); #else builder.RegisterType <DiscoveryMultiplexer>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DiscoveryClient>() .AsImplementedInterfaces().SingleInstance(); #endif // TODO: Add more jobs return(builder); }
/// <summary> /// Autofac configuration. /// </summary> /// <param name="builder"></param> public virtual void ConfigureContainer(ContainerBuilder builder) { // Register service info and configuration interfaces builder.RegisterInstance(ServiceInfo) .AsImplementedInterfaces().SingleInstance(); builder.RegisterInstance(Config) .AsImplementedInterfaces().SingleInstance(); // Register logger builder.RegisterLogger(LogEx.ApplicationInsights(Config, Config.Configuration)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // CORS setup builder.RegisterType <CorsSetup>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); // ... with bearer auth if (Config.AuthRequired) { builder.RegisterType <BehalfOfTokenProvider>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DistributedTokenCache>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HttpBearerAuthentication>() .AsImplementedInterfaces().SingleInstance(); } builder.RegisterType <JwtTokenValidator>() .AsImplementedInterfaces().SingleInstance(); // Iot hub services builder.RegisterType <IoTHubServiceHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubMessagingHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubTwinMethodClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ChunkMethodClient>() .AsImplementedInterfaces().SingleInstance(); // Register registry micro service adapter builder.RegisterType <RegistryServiceClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <RegistryAdapter>() .AsImplementedInterfaces().SingleInstance(); // Todo: register twin micro service adapter builder.RegisterType <TwinClient>() .AsImplementedInterfaces().SingleInstance(); // Auto start listeners builder.RegisterType <TcpChannelListener>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <WebSocketChannelListener>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <HttpChannelListener>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <StackLogger>() .AutoActivate() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <SessionServices>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <MessageSerializer>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <JsonVariantEncoder>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <GatewayServer>() .AsImplementedInterfaces().SingleInstance(); }
/// <summary> /// Autofac configuration. /// </summary> public static ContainerBuilder ConfigureContainer( IConfigurationRoot configuration) { var serviceInfo = new ServiceInfo(); var config = new Config(configuration); var builder = new ContainerBuilder(); builder.RegisterInstance(serviceInfo) .AsImplementedInterfaces().SingleInstance(); // Register configuration interfaces builder.RegisterInstance(config) .AsImplementedInterfaces().SingleInstance(); // register logger builder.RegisterLogger(LogEx.ApplicationInsights(configuration, config)); // Register metrics logger builder.RegisterType <MetricLogger>() .AsImplementedInterfaces().SingleInstance(); // Register http client module builder.RegisterModule <HttpClientModule>(); #if DEBUG builder.RegisterType <NoOpCertValidator>() .AsImplementedInterfaces(); #endif // Cosmos db storage builder.RegisterType <ItemContainerFactory>() .AsImplementedInterfaces(); builder.RegisterType <CosmosDbServiceClient>() .AsImplementedInterfaces(); // Iot hub services builder.RegisterType <IoTHubServiceHttpClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <IoTHubTwinMethodClient>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ChunkMethodClient>() .AsImplementedInterfaces().SingleInstance(); // Event processor services for onboarding consumer builder.RegisterType <EventProcessorHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <EventProcessorFactory>() .AsImplementedInterfaces().SingleInstance(); // Handle discovery events from opc twin module builder.RegisterType <IoTHubDeviceEventHandler>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DiscoveryEventHandler>() .AsImplementedInterfaces().SingleInstance(); // Register event bus to publish events builder.RegisterType <EventBusHost>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusClientFactory>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ServiceBusEventBus>() .AsImplementedInterfaces().SingleInstance(); // Registries and repositories builder.RegisterModule <RegistryServices>(); #if !USE_APP_DB // TODO: Decide whether when to switch builder.RegisterType <ApplicationTwins>() .AsImplementedInterfaces().SingleInstance(); #else builder.RegisterType <ApplicationDatabase>() .AsImplementedInterfaces().SingleInstance(); #endif // Finally add discovery processing and activation builder.RegisterType <DiscoveryProcessor>() .AsImplementedInterfaces().SingleInstance(); builder.RegisterType <ActivationClient>() .AsImplementedInterfaces().SingleInstance(); return(builder); }