-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added service registration extensions
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ZeroRedact | ||
{ | ||
/// <summary> | ||
/// Extension methods for <see cref="IServiceCollection"/> to register <see cref="IRedactor"/> with the <see cref="Redactor"/> implementation. | ||
/// </summary> | ||
public static class ZeroRedactExtensions | ||
{ | ||
/// <summary> | ||
/// Registers an instance of <see cref="IRedactor"/> with the <see cref="Redactor"/> implementation. | ||
/// </summary> | ||
/// <param name="services">The service collection</param> | ||
/// <returns></returns> | ||
public static IServiceCollection AddZeroRedact(this IServiceCollection services) | ||
{ | ||
ArgumentNullException.ThrowIfNull(services); | ||
services.AddSingleton<IRedactor, Redactor>(); | ||
return services; | ||
} | ||
|
||
/// <summary> | ||
/// Registers an instance of <see cref="IRedactor"/> with the <see cref="Redactor"/> implementation with <see cref="RedactorOptions"/>. | ||
/// </summary> | ||
/// <param name="services">The service collection</param> | ||
/// <param name="options">The <see cref="RedactorOptions"/> to configure the <see cref="Redactor"/></param>. | ||
/// <returns></returns> | ||
public static IServiceCollection AddZeroRedact(this IServiceCollection services, RedactorOptions options) | ||
{ | ||
ArgumentNullException.ThrowIfNull(services); | ||
services.AddSingleton<IRedactor>(new Redactor(options)); | ||
return services; | ||
} | ||
} | ||
} |