@@ -34,37 +34,37 @@ public static IServiceCollection AddSpark(this IServiceCollection services, Acti
3434 services . Configure ( setupAction ) ;
3535 }
3636
37- // TODO: Reduce memory consumption cause by loading the assembly of the views compiled dynamically
3837 services
39- . AddSingleton < ISparkLanguageFactory , DefaultLanguageFactory > ( )
40- . AddSingleton < IRoslynCompilationLink , CSharpLink > ( )
41- . AddSingleton < IRoslynCompilationLink , VisualBasicLink > ( )
42- . AddSingleton < IBatchCompiler , RoslynBatchCompiler > ( ) ;
38+ . AddScoped < ISparkLanguageFactory , DefaultLanguageFactory > ( )
39+ . AddScoped < IRoslynCompilationLink , CSharpLink > ( )
40+ . AddScoped < IRoslynCompilationLink , VisualBasicLink > ( )
41+ . AddScoped < IBatchCompiler , RoslynBatchCompiler > ( ) ;
4342
4443 services
45- . AddSingleton < Spark . ISparkViewEngine , Spark . SparkViewEngine > ( )
46- . AddSingleton < ISparkSyntaxProvider , DefaultSyntaxProvider > ( )
44+ . AddScoped < Spark . ISparkViewEngine , Spark . SparkViewEngine > ( )
45+ . AddScoped < ISparkSyntaxProvider , DefaultSyntaxProvider > ( )
4746 . AddSingleton < IViewActivatorFactory , DefaultViewActivator > ( )
4847 . AddSingleton < IResourcePathManager , DefaultResourcePathManager > ( )
4948 . AddSingleton < ITemplateLocator , DefaultTemplateLocator > ( )
50- . AddSingleton < IBindingProvider , DefaultBindingProvider > ( )
49+ . AddScoped < IBindingProvider , DefaultBindingProvider > ( )
5150 . AddSingleton < IViewFolder > ( f => f . GetService < ISparkSettings > ( ) . CreateDefaultViewFolder ( ) )
5251 . AddSingleton < ICompiledViewHolder , CompiledViewHolder > ( )
5352 . AddSingleton < IPartialProvider , DefaultPartialProvider > ( )
5453 . AddSingleton < IPartialReferenceProvider , DefaultPartialReferenceProvider > ( ) ;
5554
56- services . AddSingleton < ISparkExtensionFactory > ( c => null ) ;
55+ services
56+ . AddSingleton < ISparkExtensionFactory > ( f => null ) ;
5757
5858 services
5959 . AddSingleton < IDescriptorBuilder , AspNetCoreDescriptorBuilder > ( ) ;
6060
6161 services
62- . AddSingleton < ISparkPrecompiler , SparkPrecompiler > ( ) ;
62+ . AddScoped < ISparkPrecompiler , SparkPrecompiler > ( ) ;
6363
6464 services
6565 . AddTransient < IConfigureOptions < MvcOptions > , SparkMvcOptionsSetup > ( )
6666 . AddTransient < IConfigureOptions < MvcViewOptions > , SparkMvcViewOptionsSetup > ( )
67- . AddSingleton < ISparkViewEngine , SparkViewEngine > ( ) ;
67+ . AddScoped < ISparkViewEngine , SparkViewEngine > ( ) ;
6868
6969 return services ;
7070 }
0 commit comments