-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Usage.cs
49 lines (35 loc) · 1.51 KB
/
Usage.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
public class Usage
{
Usage(EndpointConfiguration endpointConfiguration, IServiceCollection serviceCollection)
{
#region FluentValidation
endpointConfiguration.UseFluentValidation();
serviceCollection.AddValidatorsFromAssemblyContaining<TheMessage>();
#endregion
#region FluentValidation_disableincoming
endpointConfiguration.UseFluentValidation(incoming: false);
#endregion
#region FluentValidation_disableoutgoing
endpointConfiguration.UseFluentValidation(outgoing: false);
#endregion
}
static void AddValidators(EndpointConfiguration endpointConfiguration, Assembly assembly, IServiceCollection serviceCollection)
{
#region FluentValidation_AddValidators
endpointConfiguration.UseFluentValidation();
serviceCollection.AddValidatorsFromAssemblyContaining<MyMessage>();
serviceCollection.AddValidatorsFromAssemblyContaining(typeof(SomeOtherMessage));
serviceCollection.AddValidatorsFromAssembly(assembly);
#endregion
}
static void IgnoreValidatorConventions(EndpointConfiguration endpointConfiguration, Assembly assembly, IServiceCollection serviceCollection)
{
#region FluentValidation_IgnoreValidatorConventions
endpointConfiguration.UseFluentValidation();
serviceCollection.AddValidatorsFromAssembly(
assembly,
throwForNonPublicValidators: false,
throwForNoValidatorsFound: false);
#endregion
}
}