Skip to content

Commit

Permalink
TryAddSingleton for overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jzabroski committed Jun 30, 2020
1 parent 3652882 commit cc9ab96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/RazorLight/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using RazorLight.DependencyInjection;

namespace RazorLight.Extensions
Expand All @@ -19,8 +20,8 @@ public static void AddRazorLight(this IServiceCollection services, Func<IRazorLi
}

services.AddSingleton<PropertyInjector>();
services.AddSingleton<IEngineHandler, EngineHandler>();
services.AddSingleton<IRazorLightEngine>(p =>
services.TryAddSingleton<IEngineHandler, EngineHandler>();
services.TryAddSingleton<IRazorLightEngine>(p =>
{
var engine = engineFactoryProvider();
AddEngineRenderCallbacks(engine, p);
Expand Down

0 comments on commit cc9ab96

Please sign in to comment.