-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TargetFramework to .NET 7 (#112)
* Update TargetFramework to .NET 7 * Update projects to reflect modern .NET patterns * Update README * Update package versions from 4.2.0 -> 7.0.0 * rename method * update packages * Update release notes and CI pipelines for .NET 7 * Use .NEt 7.x and update unit test project to .NET 7 * update package release notes
- Loading branch information
1 parent
e545953
commit 8432b42
Showing
28 changed files
with
177 additions
and
203 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
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
4 changes: 2 additions & 2 deletions
4
sample/Ardalis.Result.Sample.Core/Ardalis.Result.Sample.Core.csproj
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
8 changes: 4 additions & 4 deletions
8
sample/Ardalis.Result.Sample.UnitTests/Ardalis.Result.Sample.UnitTests.csproj
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
8 changes: 4 additions & 4 deletions
8
...t.SampleMinimalApi.FunctionalTests/Ardalis.Result.SampleMinimalApi.FunctionalTests.csproj
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
8 changes: 4 additions & 4 deletions
8
.../Ardalis.Result.SampleWeb.FunctionalTests/Ardalis.Result.SampleWeb.FunctionalTests.csproj
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
6 changes: 3 additions & 3 deletions
6
sample/Ardalis.Result.SampleWeb/Ardalis.Result.SampleWeb.csproj
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 |
---|---|---|
@@ -1,19 +1,70 @@ | ||
using Ardalis.Result; | ||
using Ardalis.Result.AspNetCore; | ||
using Ardalis.Result.Sample.Core.Services; | ||
using Ardalis.Result.SampleWeb.MediatrApi; | ||
using MediatR; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Localization; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Options; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Net; | ||
|
||
namespace Ardalis.Result.SampleWeb; | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
public class Program | ||
var webAssembly = typeof(Program).Assembly; | ||
builder.Services.AddMediatR(webAssembly); | ||
builder.Services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); | ||
|
||
builder.Services.AddControllers(mvcOptions => mvcOptions | ||
.AddResultConvention(resultStatusMap => resultStatusMap | ||
.AddDefaultMap() | ||
.For(ResultStatus.Ok, HttpStatusCode.OK, resultStatusOptions => resultStatusOptions | ||
.For("POST", HttpStatusCode.Created) | ||
.For("DELETE", HttpStatusCode.NoContent)) | ||
.Remove(ResultStatus.Forbidden) | ||
.Remove(ResultStatus.Unauthorized) | ||
)); | ||
|
||
builder.Services.AddRazorPages(); | ||
builder.Services.AddLocalization(opt => { opt.ResourcesPath = "Resources"; }); | ||
builder.Services.Configure<RequestLocalizationOptions>(options => | ||
{ | ||
var supportedCultures = new List<CultureInfo> | ||
{ | ||
new CultureInfo("en-US"), | ||
new CultureInfo("de-DE"), | ||
}; | ||
options.DefaultRequestCulture = new RequestCulture("en-US"); | ||
options.SupportedCultures = supportedCultures; | ||
options.SupportedUICultures = supportedCultures; | ||
}); | ||
|
||
builder.Services.AddSwaggerGen(); | ||
builder.Services.AddTransient<PersonService>(); | ||
builder.Services.AddTransient<WeatherService>(); | ||
builder.Services.AddTransient<WeatherServiceWithExceptions>(); | ||
|
||
var app = builder.Build(); | ||
|
||
if (builder.Environment.IsDevelopment()) | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseRouting(); | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1")); | ||
|
||
var options = app.Services.GetService<IOptions<RequestLocalizationOptions>>(); | ||
app.UseRequestLocalization(options.Value); | ||
|
||
app.MapControllers(); | ||
app.MapRazorPages(); | ||
|
||
app.Run(); |
Oops, something went wrong.