Skip to content

Commit d4d9f76

Browse files
authored
Merge pull request #67 from kolan72/dev-di
Update main before release.
2 parents 738ad9e + bc42f88 commit d4d9f76

File tree

44 files changed

+1709
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1709
-417
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<InvariantGlobalization>true</InvariantGlobalization>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Content Remove="Properties\launchSettings.json" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\..\src\ExpressValidator.Extensions.DependencyInjection\ExpressValidator.Extensions.DependencyInjection.csproj" />
16+
<ProjectReference Include="..\Shared\Shared.csproj" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<None Include="Properties\launchSettings.json" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using ExpressValidator.Extensions.DependencyInjection;
2+
using ExpressValidator;
3+
using FluentValidation;
4+
using Shared;
5+
6+
namespace ConfiguratorDemo
7+
{
8+
public class GuessValidatorConfigurator : ValidatorConfigurator<ObjToValidate>
9+
{
10+
public override void Configure(ExpressValidatorBuilder<ObjToValidate> expressValidatorBuilder)
11+
=> expressValidatorBuilder
12+
.AddProperty(o => o.I)
13+
.WithValidation((o) => o.GreaterThan(5));
14+
}
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using ExpressValidator.Extensions.DependencyInjection;
2+
using Shared;
3+
using System.Reflection;
4+
5+
namespace ConfiguratorDemo
6+
{
7+
public static class Program
8+
{
9+
public static void Main(string[] args)
10+
{
11+
var builder = WebApplication.CreateBuilder(args);
12+
13+
builder.Services.AddExpressValidation(Assembly.GetExecutingAssembly());
14+
15+
builder.Services.AddTransient<IGuessTheNumberService, GuessTheNumberService>();
16+
17+
var app = builder.Build();
18+
19+
app.MapGet("/guess", (IGuessTheNumberService service) =>
20+
{
21+
var (Result, Message) = service.Guess();
22+
if (!Result)
23+
{
24+
return Results.BadRequest(Message);
25+
}
26+
else
27+
{
28+
return Results.Ok(Message);
29+
}
30+
});
31+
32+
app.Run();
33+
}
34+
}
35+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"profiles": {
3+
"ConfiguratorDemo": {
4+
"commandName": "Project",
5+
"launchBrowser": true,
6+
"launchUrl": "guess",
7+
"environmentVariables": {
8+
"ASPNETCORE_ENVIRONMENT": "Development"
9+
},
10+
"applicationUrl": "https://localhost:56889;http://localhost:56890"
11+
}
12+
}
13+
}

samples/ExpressValidator.Extensions.DependencyInjection.Sample/appsettings.Development.json renamed to samples/ExpressValidator.Extensions.DependencyInjection.Sample/ConfiguratorDemo/appsettings.Development.json

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

samples/ExpressValidator.Extensions.DependencyInjection.Sample/ExpressValidator.Extensions.DependencyInjection.Sample.csproj

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/ExpressValidator.Extensions.DependencyInjection.Sample/ExpressValidator.Extensions.DependencyInjection.Sample.sln

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,48 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.8.34330.188
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressValidator.Extensions.DependencyInjection.Sample", "ExpressValidator.Extensions.DependencyInjection.Sample.csproj", "{C934656A-07B3-4909-9C4E-0DC71D2FD62F}"
7-
EndProject
86
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressValidator.Extensions.DependencyInjection", "..\..\src\ExpressValidator.Extensions.DependencyInjection\ExpressValidator.Extensions.DependencyInjection.csproj", "{FF31B329-336C-47F0-BA60-55893A6FBCED}"
97
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickStart", "QuickStart\QuickStart.csproj", "{6C698590-8D21-5D95-CEA6-33121ACA75F1}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValidatorBuilderWithOptions", "ValidatorBuilderWithOptions\ValidatorBuilderWithOptions.csproj", "{FC01EFE1-3E2D-48C7-9A5B-0F14E892F0C3}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfiguratorDemo", "ConfiguratorDemo\ConfiguratorDemo.csproj", "{B7782C5A-65E8-4FB9-B0CF-4BC0657CB294}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{773987E2-48B5-4E06-A211-568C85655B72}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValidatorWithReload", "ValidatorWithReload\ValidatorWithReload.csproj", "{2F1D27FB-7F89-4502-AEC9-50E1737769B7}"
17+
EndProject
1018
Global
1119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1220
Debug|Any CPU = Debug|Any CPU
1321
Release|Any CPU = Release|Any CPU
1422
EndGlobalSection
1523
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{C934656A-07B3-4909-9C4E-0DC71D2FD62F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{C934656A-07B3-4909-9C4E-0DC71D2FD62F}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{C934656A-07B3-4909-9C4E-0DC71D2FD62F}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{C934656A-07B3-4909-9C4E-0DC71D2FD62F}.Release|Any CPU.Build.0 = Release|Any CPU
2024
{FF31B329-336C-47F0-BA60-55893A6FBCED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2125
{FF31B329-336C-47F0-BA60-55893A6FBCED}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{FF31B329-336C-47F0-BA60-55893A6FBCED}.Release|Any CPU.ActiveCfg = Release|Any CPU
2327
{FF31B329-336C-47F0-BA60-55893A6FBCED}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{6C698590-8D21-5D95-CEA6-33121ACA75F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{6C698590-8D21-5D95-CEA6-33121ACA75F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{6C698590-8D21-5D95-CEA6-33121ACA75F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{6C698590-8D21-5D95-CEA6-33121ACA75F1}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{FC01EFE1-3E2D-48C7-9A5B-0F14E892F0C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{FC01EFE1-3E2D-48C7-9A5B-0F14E892F0C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{FC01EFE1-3E2D-48C7-9A5B-0F14E892F0C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{FC01EFE1-3E2D-48C7-9A5B-0F14E892F0C3}.Release|Any CPU.Build.0 = Release|Any CPU
36+
{B7782C5A-65E8-4FB9-B0CF-4BC0657CB294}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{B7782C5A-65E8-4FB9-B0CF-4BC0657CB294}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{B7782C5A-65E8-4FB9-B0CF-4BC0657CB294}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{B7782C5A-65E8-4FB9-B0CF-4BC0657CB294}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{773987E2-48B5-4E06-A211-568C85655B72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{773987E2-48B5-4E06-A211-568C85655B72}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{773987E2-48B5-4E06-A211-568C85655B72}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{773987E2-48B5-4E06-A211-568C85655B72}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{2F1D27FB-7F89-4502-AEC9-50E1737769B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{2F1D27FB-7F89-4502-AEC9-50E1737769B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{2F1D27FB-7F89-4502-AEC9-50E1737769B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{2F1D27FB-7F89-4502-AEC9-50E1737769B7}.Release|Any CPU.Build.0 = Release|Any CPU
2448
EndGlobalSection
2549
GlobalSection(SolutionProperties) = preSolution
2650
HideSolutionNode = FALSE

samples/ExpressValidator.Extensions.DependencyInjection.Sample/Program.cs

Lines changed: 0 additions & 198 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using ExpressValidator.Extensions.DependencyInjection;
2+
using FluentValidation;
3+
using Shared;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
builder.Services.AddExpressValidator<ObjToValidate>(b =>
8+
b.AddProperty(o => o.I)
9+
.WithValidation(o => o.GreaterThan(5)
10+
.WithMessage("Must be greater than 5!")));
11+
12+
builder.Services.AddTransient<IGuessTheNumberService, GuessTheNumberService>();
13+
14+
var app = builder.Build();
15+
16+
app.MapGet("/guess", (IGuessTheNumberService service) =>
17+
{
18+
var (Result, Message) = service.Guess();
19+
if (!Result)
20+
{
21+
return Results.BadRequest(Message);
22+
}
23+
else
24+
{
25+
return Results.Ok(Message);
26+
}
27+
});
28+
29+
await app.RunAsync();

0 commit comments

Comments
 (0)