@@ -84,19 +84,21 @@ public void SetupDatabaseRepository(IntegrationEngineContext integrationEngineCo
8484 Container . RegisterInstance < IDatabaseRepository > ( new DatabaseRepository ( integrationEngineContext ) ) ;
8585 }
8686
87+ void RegisterConfig ( Type from , Type to , string integrationPointName )
88+ {
89+ Container . RegisterType ( from , to , integrationPointName ,
90+ new InjectionConstructor ( new ResolvedParameter < IEngineConfiguration > ( ) , integrationPointName )
91+ ) ;
92+ }
93+
8794 public void RegisterIntegrationPoints ( )
8895 {
8996 Container . RegisterType < Elasticsearch . Net . Connection . IConnection , Elasticsearch . Net . Connection . HttpConnection > ( ) ;
9097 Container . RegisterType < INestSerializer , NestSerializer > ( ) ;
9198 Container . RegisterType < Elasticsearch . Net . Connection . ITransport , Elasticsearch . Net . Connection . Transport > ( ) ;
9299 Container . RegisterType < IConnectionSettingsValues , ConnectionSettings > ( ) ;
93100 foreach ( var config in EngineConfiguration . IntegrationPoints . Mail ) {
94- Container . RegisterType < IMailConfiguration , MailConfiguration > ( config . IntegrationPointName ,
95- new InjectionConstructor (
96- new ResolvedParameter < IEngineConfiguration > ( ) ,
97- config . IntegrationPointName
98- )
99- ) ;
101+ RegisterConfig ( typeof ( IMailConfiguration ) , typeof ( MailConfiguration ) , config . IntegrationPointName ) ;
100102 Container . RegisterType < IMailClient , MailClient > ( config . IntegrationPointName , new InjectionConstructor ( config ) ) ;
101103 }
102104
@@ -107,31 +109,15 @@ public void RegisterIntegrationPoints()
107109 return new ElasticClient ( settings ) ;
108110 } ;
109111 foreach ( var config in EngineConfiguration . IntegrationPoints . Elasticsearch ) {
110- Container . RegisterType < IElasticsearchConfiguration , ElasticsearchConfiguration > ( config . IntegrationPointName ,
111- new InjectionConstructor (
112- new ResolvedParameter < IEngineConfiguration > ( ) ,
113- config . IntegrationPointName
114- )
115- ) ;
116- Container . RegisterType < IElasticClient , ElasticClientAdapter > ( config . IntegrationPointName ,
117- new InjectionFactory ( elasticClientFactory ) ) ;
112+ RegisterConfig ( typeof ( IElasticsearchConfiguration ) , typeof ( ElasticsearchConfiguration ) , config . IntegrationPointName ) ;
113+ Container . RegisterType < IElasticClient , ElasticClientAdapter > ( config . IntegrationPointName , new InjectionFactory ( elasticClientFactory ) ) ;
118114 }
119115 foreach ( var config in EngineConfiguration . IntegrationPoints . RabbitMQ ) {
120- Container . RegisterType < IRabbitMQConfiguration , RabbitMQConfiguration > ( config . IntegrationPointName ,
121- new InjectionConstructor (
122- new ResolvedParameter < IEngineConfiguration > ( ) ,
123- config . IntegrationPointName
124- )
125- ) ;
116+ RegisterConfig ( typeof ( IRabbitMQConfiguration ) , typeof ( RabbitMQConfiguration ) , config . IntegrationPointName ) ;
126117 Container . RegisterType < IRabbitMQClient , RabbitMQClient > ( config . IntegrationPointName , new InjectionConstructor ( config ) ) ;
127118 }
128119 foreach ( var config in EngineConfiguration . IntegrationPoints . JsonService ) {
129- Container . RegisterType < IJsonServiceConfiguration , JsonServiceConfiguration > ( config . IntegrationPointName ,
130- new InjectionConstructor (
131- new ResolvedParameter < IEngineConfiguration > ( ) ,
132- config . IntegrationPointName
133- )
134- ) ;
120+ RegisterConfig ( typeof ( IJsonServiceConfiguration ) , typeof ( JsonServiceConfiguration ) , config . IntegrationPointName ) ;
135121 Container . RegisterType < IJsonServiceClient , JsonServiceClientAdapter > ( config . IntegrationPointName , new InjectionConstructor ( config ) ) ;
136122 }
137123 }
0 commit comments