-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup(Mapster): Integrate Mapster into the project:
- Added Mapster - Refactored infrastructure registration in Program.cs
- Loading branch information
1 parent
1251b70
commit 87f64e2
Showing
3 changed files
with
35 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Mapster; | ||
using MapsterMapper; | ||
using System.Reflection; | ||
using StellarChat.Shared.Infrastructure; | ||
|
||
namespace StellarChat.Server.Api; | ||
|
||
internal static class Extensions | ||
{ | ||
public static void AddInfrastructure(this WebApplicationBuilder builder) | ||
{ | ||
builder.AddSharedInfrastructure(); | ||
|
||
builder.Services.AddMappings(); | ||
} | ||
|
||
public static WebApplication UseInfrastructure(this WebApplication app) | ||
=> app.UseSharedInfrastructure(); | ||
|
||
public static IServiceCollection AddMappings(this IServiceCollection services) | ||
{ | ||
var config = TypeAdapterConfig.GlobalSettings; | ||
config.Scan(Assembly.GetExecutingAssembly()); | ||
|
||
services.AddSingleton(config); | ||
services.AddScoped<IMapper, ServiceMapper>(); | ||
|
||
return services; | ||
} | ||
} |
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,11 +1,11 @@ | ||
using StellarChat.Shared.Infrastructure; | ||
using StellarChat.Server.Api; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.AddSharedInfrastructure(); | ||
builder.AddInfrastructure(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseSharedInfrastructure(); | ||
app.UseInfrastructure(); | ||
|
||
app.Run(); |
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