-
Notifications
You must be signed in to change notification settings - Fork 42
/
SerilogUiOptionsBuilderExtensions.cs
57 lines (48 loc) · 2.1 KB
/
SerilogUiOptionsBuilderExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using Microsoft.Extensions.DependencyInjection;
using Serilog.Ui.Core.Interfaces;
namespace Serilog.Ui.Core.Extensions;
/// <summary>
/// SerilogUiOptionsBuilderExtensions.
/// </summary>
public static class SerilogUiOptionsBuilderExtensions
{
/// <summary>
/// Add <typeparamref name="T"/> as scoped service implementation of <see cref="IUiAsyncAuthorizationFilter"/>,
/// using an implementation factory.
/// </summary>
public static ISerilogUiOptionsBuilder AddScopedAsyncAuthFilter<T>(this ISerilogUiOptionsBuilder builder,
Func<IServiceProvider, T> implementationFactory) where T : class, IUiAsyncAuthorizationFilter
{
builder.Services.AddScoped<IUiAsyncAuthorizationFilter, T>(implementationFactory);
return builder;
}
/// <summary>
/// Add <typeparamref name="T"/> as scoped service implementation of <see cref="IUiAsyncAuthorizationFilter"/>.
/// </summary>
public static ISerilogUiOptionsBuilder AddScopedAsyncAuthFilter<T>(this ISerilogUiOptionsBuilder builder)
where T : class, IUiAsyncAuthorizationFilter
{
builder.Services.AddScoped<IUiAsyncAuthorizationFilter, T>();
return builder;
}
/// <summary>
/// Add <typeparamref name="T"/> as scoped service implementation of <see cref="IUiAuthorizationFilter"/>,
/// using an implementation factory.
/// </summary>
public static ISerilogUiOptionsBuilder AddScopedSyncAuthFilter<T>(this ISerilogUiOptionsBuilder builder,
Func<IServiceProvider, T> implementationFactory) where T : class, IUiAuthorizationFilter
{
builder.Services.AddScoped<IUiAuthorizationFilter, T>(implementationFactory);
return builder;
}
/// <summary>
/// Add <typeparamref name="T"/> as scoped service implementation of <see cref="IUiAuthorizationFilter"/>.
/// </summary>
public static ISerilogUiOptionsBuilder AddScopedSyncAuthFilter<T>(this ISerilogUiOptionsBuilder builder)
where T : class, IUiAuthorizationFilter
{
builder.Services.AddScoped<IUiAuthorizationFilter, T>();
return builder;
}
}