From 7723d7beb5c146b29338ec3e14d52f4b6e36e4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Kuklau?= Date: Fri, 22 Sep 2023 13:03:02 +0200 Subject: [PATCH] add AddRazorEmailRenderer for more convenient (and correct) setup --- TRENZ.Lib.RazorMail.SampleWebApi/Program.cs | 7 ++----- .../RazorMailServiceCollectionExtensions.cs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 TRENZ.Lib.RazorMail/Extensions/RazorMailServiceCollectionExtensions.cs diff --git a/TRENZ.Lib.RazorMail.SampleWebApi/Program.cs b/TRENZ.Lib.RazorMail.SampleWebApi/Program.cs index 85385cb..5088c26 100644 --- a/TRENZ.Lib.RazorMail.SampleWebApi/Program.cs +++ b/TRENZ.Lib.RazorMail.SampleWebApi/Program.cs @@ -1,11 +1,8 @@ -using TRENZ.Lib.RazorMail.Services; +using TRENZ.Lib.RazorMail.Extensions; var builder = WebApplication.CreateBuilder(args); -builder.Services.AddMvcCore() - .AddRazorViewEngine(); - -builder.Services.AddTransient(); +builder.Services.AddRazorEmailRenderer(); var app = builder.Build(); diff --git a/TRENZ.Lib.RazorMail/Extensions/RazorMailServiceCollectionExtensions.cs b/TRENZ.Lib.RazorMail/Extensions/RazorMailServiceCollectionExtensions.cs new file mode 100644 index 0000000..f10805d --- /dev/null +++ b/TRENZ.Lib.RazorMail/Extensions/RazorMailServiceCollectionExtensions.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.DependencyInjection; + +using TRENZ.Lib.RazorMail.Services; + +namespace TRENZ.Lib.RazorMail.Extensions; + +public static class RazorMailServiceCollectionExtensions +{ + public static IServiceCollection AddRazorEmailRenderer(this IServiceCollection services) + { + services.AddMvcCore() + .AddRazorViewEngine(); + + services.AddTransient(); + + return services; + } +} \ No newline at end of file