Skip to content

Commit

Permalink
Merge pull request #82 from SparkViewEngine/ioc-registration-improvem…
Browse files Browse the repository at this point in the history
…ents

No longer leaking memory
  • Loading branch information
RobertTheGrey authored Dec 18, 2024
2 parents d7b703e + 1018476 commit 2e2f732
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Spark.AspNetCore.Mvc/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@ public static IServiceCollection AddSpark(this IServiceCollection services, Acti
services.Configure(setupAction);
}

// TODO: Reduce memory consumption cause by loading the assembly of the views compiled dynamically
services
.AddSingleton<ISparkLanguageFactory, DefaultLanguageFactory>()
.AddSingleton<IRoslynCompilationLink, CSharpLink>()
.AddSingleton<IRoslynCompilationLink, VisualBasicLink>()
.AddSingleton<IBatchCompiler, RoslynBatchCompiler>();
.AddScoped<ISparkLanguageFactory, DefaultLanguageFactory>()
.AddScoped<IRoslynCompilationLink, CSharpLink>()
.AddScoped<IRoslynCompilationLink, VisualBasicLink>()
.AddScoped<IBatchCompiler, RoslynBatchCompiler>();

services
.AddSingleton<Spark.ISparkViewEngine, Spark.SparkViewEngine>()
.AddSingleton<ISparkSyntaxProvider, DefaultSyntaxProvider>()
.AddScoped<Spark.ISparkViewEngine, Spark.SparkViewEngine>()
.AddScoped<ISparkSyntaxProvider, DefaultSyntaxProvider>()
.AddSingleton<IViewActivatorFactory, DefaultViewActivator>()
.AddSingleton<IResourcePathManager, DefaultResourcePathManager>()
.AddSingleton<ITemplateLocator, DefaultTemplateLocator>()
.AddSingleton<IBindingProvider, DefaultBindingProvider>()
.AddScoped<IBindingProvider, DefaultBindingProvider>()
.AddSingleton<IViewFolder>(f => f.GetService<ISparkSettings>().CreateDefaultViewFolder())
.AddSingleton<ICompiledViewHolder, CompiledViewHolder>()
.AddSingleton<IPartialProvider, DefaultPartialProvider>()
.AddSingleton<IPartialReferenceProvider, DefaultPartialReferenceProvider>();

services.AddSingleton<ISparkExtensionFactory>(c => null);
services
.AddSingleton<ISparkExtensionFactory>(f => null);

services
.AddSingleton<IDescriptorBuilder, AspNetCoreDescriptorBuilder>();

services
.AddSingleton<ISparkPrecompiler, SparkPrecompiler>();
.AddScoped<ISparkPrecompiler, SparkPrecompiler>();

services
.AddTransient<IConfigureOptions<MvcOptions>, SparkMvcOptionsSetup>()
.AddTransient<IConfigureOptions<MvcViewOptions>, SparkMvcViewOptionsSetup>()
.AddSingleton<ISparkViewEngine, SparkViewEngine>();
.AddScoped<ISparkViewEngine, SparkViewEngine>();

return services;
}
Expand Down

0 comments on commit 2e2f732

Please sign in to comment.