@@ -158,15 +158,7 @@ private void RegisterConfiguration(IWindsorContainer container, Assembly[] assem
158
158
{
159
159
foreach ( var assembly in assembliesToRegister )
160
160
{
161
- var assemblyTypes = assembly . DefinedTypes
162
- . Where ( w =>
163
- {
164
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
165
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
166
-
167
- return attribute == null ||
168
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
169
- } ) ;
161
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
170
162
171
163
container . Register ( Classes . From ( assemblyTypes )
172
164
. InSameNamespaceAs < Configuration > ( )
@@ -198,15 +190,7 @@ private void ApplyDefaultInterfaceConvention(IWindsorContainer container, Assemb
198
190
{
199
191
foreach ( var assembly in assembliesToRegister )
200
192
{
201
- var assemblyTypes = assembly . DefinedTypes
202
- . Where ( w =>
203
- {
204
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
205
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
206
-
207
- return attribute == null ||
208
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
209
- } ) ;
193
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
210
194
211
195
assemblyTypes . Any ( t => t . Name == nameof ( IMessageBox ) ) ;
212
196
@@ -227,15 +211,7 @@ private void RegisterFactories(IWindsorContainer container, Assembly[] assemblie
227
211
{
228
212
foreach ( var assembly in assembliesToRegister )
229
213
{
230
- var assemblyTypes = assembly . DefinedTypes
231
- . Where ( w =>
232
- {
233
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
234
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
235
-
236
- return attribute == null ||
237
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
238
- } ) ;
214
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
239
215
240
216
container . Register ( Types . From ( assemblyTypes )
241
217
. Where ( type => type . IsInterface && type . Name . EndsWith ( "Factory" ) )
@@ -258,15 +234,7 @@ private void RegisterQuickFixes(IWindsorContainer container, Assembly[] assembli
258
234
{
259
235
foreach ( var assembly in assembliesToRegister )
260
236
{
261
- var assemblyTypes = assembly . DefinedTypes
262
- . Where ( w =>
263
- {
264
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
265
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
266
-
267
- return attribute == null ||
268
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
269
- } ) ;
237
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
270
238
271
239
container . Register ( Classes . From ( assemblyTypes )
272
240
. BasedOn < IQuickFix > ( )
@@ -280,15 +248,7 @@ private void RegisterInspections(IWindsorContainer container, Assembly[] assembl
280
248
{
281
249
foreach ( var assembly in assembliesToRegister )
282
250
{
283
- var assemblyTypes = assembly . DefinedTypes
284
- . Where ( w =>
285
- {
286
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
287
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
288
-
289
- return attribute == null ||
290
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled && a . IsEnabled ) ;
291
- } ) ;
251
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
292
252
293
253
container . Register ( Classes . From ( assemblyTypes )
294
254
. BasedOn < IInspection > ( )
@@ -301,15 +261,7 @@ private void RegisterParseTreeInspections(IWindsorContainer container, Assembly[
301
261
{
302
262
foreach ( var assembly in assembliesToRegister )
303
263
{
304
- var assemblyTypes = assembly . DefinedTypes
305
- . Where ( w =>
306
- {
307
- var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
308
- var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
309
-
310
- return attribute == null ||
311
- _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
312
- } ) ;
264
+ var assemblyTypes = GetIoCRegisteredTypes ( assembly ) ;
313
265
314
266
container . Register ( Classes . From ( assemblyTypes )
315
267
. BasedOn < IParseTreeInspection > ( )
@@ -918,5 +870,18 @@ private static void RegisterHotkeyFactory(IWindsorContainer container)
918
870
{
919
871
container . Register ( Component . For < HotkeyFactory > ( ) . LifestyleSingleton ( ) ) ;
920
872
}
873
+
874
+ private IEnumerable < TypeInfo > GetIoCRegisteredTypes ( Assembly assembly )
875
+ {
876
+ return assembly . DefinedTypes
877
+ . Where ( w =>
878
+ {
879
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
880
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
881
+
882
+ return attribute == null ||
883
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
884
+ } ) ;
885
+ }
921
886
}
922
887
}
0 commit comments