@@ -34,37 +34,37 @@ public static IServiceCollection AddSpark(this IServiceCollection services, Acti
34
34
services . Configure ( setupAction ) ;
35
35
}
36
36
37
- // TODO: Reduce memory consumption cause by loading the assembly of the views compiled dynamically
38
37
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 > ( ) ;
43
42
44
43
services
45
- . AddSingleton < Spark . ISparkViewEngine , Spark . SparkViewEngine > ( )
46
- . AddSingleton < ISparkSyntaxProvider , DefaultSyntaxProvider > ( )
44
+ . AddScoped < Spark . ISparkViewEngine , Spark . SparkViewEngine > ( )
45
+ . AddScoped < ISparkSyntaxProvider , DefaultSyntaxProvider > ( )
47
46
. AddSingleton < IViewActivatorFactory , DefaultViewActivator > ( )
48
47
. AddSingleton < IResourcePathManager , DefaultResourcePathManager > ( )
49
48
. AddSingleton < ITemplateLocator , DefaultTemplateLocator > ( )
50
- . AddSingleton < IBindingProvider , DefaultBindingProvider > ( )
49
+ . AddScoped < IBindingProvider , DefaultBindingProvider > ( )
51
50
. AddSingleton < IViewFolder > ( f => f . GetService < ISparkSettings > ( ) . CreateDefaultViewFolder ( ) )
52
51
. AddSingleton < ICompiledViewHolder , CompiledViewHolder > ( )
53
52
. AddSingleton < IPartialProvider , DefaultPartialProvider > ( )
54
53
. AddSingleton < IPartialReferenceProvider , DefaultPartialReferenceProvider > ( ) ;
55
54
56
- services . AddSingleton < ISparkExtensionFactory > ( c => null ) ;
55
+ services
56
+ . AddSingleton < ISparkExtensionFactory > ( f => null ) ;
57
57
58
58
services
59
59
. AddSingleton < IDescriptorBuilder , AspNetCoreDescriptorBuilder > ( ) ;
60
60
61
61
services
62
- . AddSingleton < ISparkPrecompiler , SparkPrecompiler > ( ) ;
62
+ . AddScoped < ISparkPrecompiler , SparkPrecompiler > ( ) ;
63
63
64
64
services
65
65
. AddTransient < IConfigureOptions < MvcOptions > , SparkMvcOptionsSetup > ( )
66
66
. AddTransient < IConfigureOptions < MvcViewOptions > , SparkMvcViewOptionsSetup > ( )
67
- . AddSingleton < ISparkViewEngine , SparkViewEngine > ( ) ;
67
+ . AddScoped < ISparkViewEngine , SparkViewEngine > ( ) ;
68
68
69
69
return services ;
70
70
}
0 commit comments