11using Microsoft . AspNetCore . Builder ;
22using Microsoft . AspNetCore . Hosting ;
33using Microsoft . Extensions . DependencyInjection ;
4- using Microsoft . Extensions . Hosting ;
54using Microsoft . Extensions . Logging ;
65
76namespace Calabonga . AspNetCore . AppDefinitions ;
@@ -27,7 +26,7 @@ public static void AddDefinitions(this IServiceCollection source, WebApplication
2726 var types = entryPoint . Assembly . ExportedTypes . Where ( x => ! x . IsAbstract && typeof ( IAppDefinition ) . IsAssignableFrom ( x ) ) ;
2827 var instances = types . Select ( Activator . CreateInstance ) . Cast < IAppDefinition > ( ) . ToList ( ) ;
2928 var instancesOrdered = instances . Where ( x => x . Enabled ) . OrderBy ( x => x . OrderIndex ) . ToList ( ) ;
30- if ( builder . Environment . IsDevelopment ( ) )
29+ if ( logger . IsEnabled ( LogLevel . Debug ) )
3130 {
3231 logger . LogDebug ( @"[AppDefinitions] Founded: {AppDefinitionsCountTotal}. Enabled: {AppDefinitionsCountEnabled}" , instances . Count , instancesOrdered . Count ) ;
3332 logger . LogDebug ( @"[AppDefinitions] Registered [{Total}]" , string . Join ( ", " , instancesOrdered . Select ( x => x . GetType ( ) . Name ) . ToArray ( ) ) ) ;
@@ -54,10 +53,10 @@ public static void UseDefinitions(this WebApplication source)
5453 var environment = source . Services . GetRequiredService < IWebHostEnvironment > ( ) ;
5554 var definitions = source . Services . GetRequiredService < IReadOnlyCollection < IAppDefinition > > ( ) ;
5655 var instancesOrdered = definitions . Where ( x => x . Enabled ) . OrderBy ( x => x . OrderIndex ) . ToList ( ) ;
57-
56+
5857 instancesOrdered . ForEach ( x => x . ConfigureApplication ( source ) ) ;
5958
60- if ( environment . IsDevelopment ( ) )
59+ if ( logger . IsEnabled ( LogLevel . Debug ) )
6160 {
6261 logger . LogDebug ( "Total application definitions configured {Count}" , instancesOrdered . Count ) ;
6362 }
0 commit comments