Format ./web/backend/Infrastructure/Infrastructure.Email.Templates

This commit is contained in:
Aaron Po
2026-06-20 15:13:01 -04:00
parent a37f2971a7
commit 0933ded022
3 changed files with 14 additions and 31 deletions

View File

@@ -6,21 +6,15 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<SupportedPlatform Include="browser"/> <SupportedPlatform Include="browser" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.1" />
<PackageReference <PackageReference
Include="Microsoft.AspNetCore.Components.Web" Include="Microsoft.Extensions.DependencyInjection.Abstractions"
Version="10.0.1" Version="10.0.1"
/>
<PackageReference
Include="Microsoft.Extensions.DependencyInjection.Abstractions"
Version="10.0.1"
/>
<PackageReference
Include="Microsoft.Extensions.Logging.Abstractions"
Version="10.0.1"
/> />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -14,10 +14,8 @@ namespace Infrastructure.Email.Templates.Rendering;
/// pipeline. /// pipeline.
/// </param> /// </param>
/// <param name="loggerFactory">The logger factory passed to the <see cref="HtmlRenderer" /> used to render components.</param> /// <param name="loggerFactory">The logger factory passed to the <see cref="HtmlRenderer" /> used to render components.</param>
public class EmailTemplateProvider( public class EmailTemplateProvider(IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
IServiceProvider serviceProvider, : IEmailTemplateProvider
ILoggerFactory loggerFactory
) : IEmailTemplateProvider
{ {
/// <summary> /// <summary>
/// Renders the UserRegisteredEmail template with the specified parameters. /// Renders the UserRegisteredEmail template with the specified parameters.
@@ -33,7 +31,7 @@ public class EmailTemplateProvider(
Dictionary<string, object?> parameters = new() Dictionary<string, object?> parameters = new()
{ {
{ nameof(UserRegistration.Username), username }, { nameof(UserRegistration.Username), username },
{ nameof(UserRegistration.ConfirmationLink), confirmationLink } { nameof(UserRegistration.ConfirmationLink), confirmationLink },
}; };
return await RenderComponentAsync<UserRegistration>(parameters); return await RenderComponentAsync<UserRegistration>(parameters);
@@ -53,7 +51,7 @@ public class EmailTemplateProvider(
Dictionary<string, object?> parameters = new() Dictionary<string, object?> parameters = new()
{ {
{ nameof(ResendConfirmation.Username), username }, { nameof(ResendConfirmation.Username), username },
{ nameof(ResendConfirmation.ConfirmationLink), confirmationLink } { nameof(ResendConfirmation.ConfirmationLink), confirmationLink },
}; };
return await RenderComponentAsync<ResendConfirmation>(parameters); return await RenderComponentAsync<ResendConfirmation>(parameters);
@@ -72,10 +70,7 @@ public class EmailTemplateProvider(
) )
where TComponent : IComponent where TComponent : IComponent
{ {
await using HtmlRenderer htmlRenderer = new( await using HtmlRenderer htmlRenderer = new(serviceProvider, loggerFactory);
serviceProvider,
loggerFactory
);
string html = await htmlRenderer.Dispatcher.InvokeAsync(async () => string html = await htmlRenderer.Dispatcher.InvokeAsync(async () =>
{ {

View File

@@ -11,10 +11,7 @@ public interface IEmailTemplateProvider
/// <param name="username">The username to include in the email</param> /// <param name="username">The username to include in the email</param>
/// <param name="confirmationLink">The email confirmation link</param> /// <param name="confirmationLink">The email confirmation link</param>
/// <returns>The rendered HTML string</returns> /// <returns>The rendered HTML string</returns>
Task<string> RenderUserRegisteredEmailAsync( Task<string> RenderUserRegisteredEmailAsync(string username, string confirmationLink);
string username,
string confirmationLink
);
/// <summary> /// <summary>
/// Renders the ResendConfirmation template with the specified parameters. /// Renders the ResendConfirmation template with the specified parameters.
@@ -22,8 +19,5 @@ public interface IEmailTemplateProvider
/// <param name="username">The username to include in the email</param> /// <param name="username">The username to include in the email</param>
/// <param name="confirmationLink">The new confirmation link</param> /// <param name="confirmationLink">The new confirmation link</param>
/// <returns>The rendered HTML string</returns> /// <returns>The rendered HTML string</returns>
Task<string> RenderResendConfirmationEmailAsync( Task<string> RenderResendConfirmationEmailAsync(string username, string confirmationLink);
string username,
string confirmationLink
);
} }