Skip to content

Commit

Permalink
Change from mapster to automapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Aug 29, 2024
1 parent 996a800 commit 3cbe1af
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 227 deletions.
4 changes: 1 addition & 3 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<DotNettyVersion>0.7.2012.2221</DotNettyVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageVersion Include="BinarySerializer" Version="8.6.4.1" />
<PackageVersion Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
Expand All @@ -15,9 +16,6 @@
<PackageVersion Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="8.1.3" />
<PackageVersion Include="EntityFrameworkCore.Exceptions.Sqlite" Version="8.1.3" />
<PackageVersion Include="LogicLooper" Version="1.6.0" />
<PackageVersion Include="Mapster" Version="7.4.1-pre01" />
<PackageVersion Include="Mapster.DependencyInjection" Version="1.0.2-pre01" />
<PackageVersion Include="Mapster.EFCore" Version="5.1.2-pre01" />
<PackageVersion Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(EfcoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Abstractions" Version="$(EfcoreVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageReference Include="Duey.Provider.WZ" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" />
<PackageReference Include="EntityFrameworkCore.Exceptions.Sqlite" />
<PackageReference Include="Mapster.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Edelstein.Application.Server.Bindings;
using AutoMapper;
using Edelstein.Application.Server.Bindings;
using Edelstein.Application.Server.Services;
using Edelstein.Protocol.Gameplay;
using Edelstein.Protocol.Network.Transports;
using Edelstein.Protocol.Plugin;
using Edelstein.Protocol.Services.Server;
using MapsterMapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down
3 changes: 1 addition & 2 deletions src/app/Edelstein.Application.Server/ProgramHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
using Edelstein.Protocol.Utilities.Repositories;
using Edelstein.Protocol.Utilities.Templates;
using Edelstein.Protocol.Utilities.Tickers;
using Mapster;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -84,7 +83,7 @@ internal static HostApplicationBuilder CreateBuilder()
break;
}

builder.Services.AddMapster();
builder.Services.AddAutoMapper(typeof(Program), typeof(GameDbContext));
builder.Services.AddPooledDbContextFactory<GameDbContext>(options =>
{
switch (builder.Configuration["DatabaseProvider"])
Expand Down
14 changes: 14 additions & 0 deletions src/app/Edelstein.Application.Server/ProgramMappingProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using AutoMapper;
using Edelstein.Application.Server.Bindings;
using Edelstein.Protocol.Services.Server.Contracts;

namespace Edelstein.Application.Server;

public class ProgramMappingProfile : Profile
{
public ProgramMappingProfile()
{
CreateMap<LoginStageSystemConfig, ServerInfoLogin>().ReverseMap();
CreateMap<GameStageSystemConfig, ServerInfoGame>().ReverseMap();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Protocol.Gameplay.Game;
using Edelstein.Protocol.Gameplay.Login;
using Edelstein.Protocol.Services.Server;
using Edelstein.Protocol.Services.Server.Contracts;
using MapsterMapper;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using R3;
Expand Down Expand Up @@ -53,7 +53,7 @@ public Task StartAsync(CancellationToken cancellationToken)
{
Info = mapper.Map<ServerInfoLogin>(login)
}),
IGameStageSystemOptions game => await service.RegisterGame(new ServerServiceRegisterRequest<ServerInfoGame>
IGameStageSystemOptions game => await service.RegisterGame(new ServerServiceRegisterRequest<ServerInfoGame>
{
Info = mapper.Map<ServerInfoGame>(game)
}),
Expand All @@ -62,7 +62,7 @@ public Task StartAsync(CancellationToken cancellationToken)

if (response.Result == ServerServiceResult.Success)
logger.LogSystemServerRegistryHostRegistered(info.ID);
else
else
logger.LogSystemServerRegistryHostRegisterFailed(info.ID, response.Result);

Secret = response.Secret ?? 0;
Expand Down
48 changes: 10 additions & 38 deletions src/app/Edelstein.Application.Server/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
"Microsoft.Data.SQLite": "8.0.0"
}
},
"Mapster.DependencyInjection": {
"type": "Direct",
"requested": "[1.0.2-pre01, )",
"resolved": "1.0.2-pre01",
"contentHash": "SYsYsi5fUeAIJGTmx4JaV2wm4A5Lz7jlmlVp4nW3RHs6WlCu/5g7heKbnJi72L1DPzFhVRCKRUq1ud1qGxiLQw==",
"dependencies": {
"Mapster": "7.4.1-pre01",
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0"
}
},
"Microsoft.Extensions.Configuration": {
"type": "Direct",
"requested": "[9.0.0-preview.7.24405.7, )",
Expand Down Expand Up @@ -229,11 +219,6 @@
"Microsoft.NETCore.Platforms": "1.0.1"
}
},
"Mapster.Core": {
"type": "Transitive",
"resolved": "1.2.2-pre01",
"contentHash": "FuNCfTHytW9yeSuGHZ9f8u4cgbzhPL0GqoypA4LD99m0zkafs73IcaMxmbUtYjRThof+Z+jcEQ/suVYTkMpTkA=="
},
"Microsoft.Data.Sqlite": {
"type": "Transitive",
"resolved": "8.0.0",
Expand Down Expand Up @@ -1531,12 +1516,11 @@
"edelstein.common.database": {
"type": "Project",
"dependencies": {
"AutoMapper": "[13.0.1, )",
"Edelstein.Common.Gameplay": "[1.0.0, )",
"Edelstein.Common.Services.Auth": "[1.0.0, )",
"Edelstein.Protocol.Services.Migration": "[1.0.0, )",
"Edelstein.Protocol.Services.Session": "[1.0.0, )",
"Mapster": "[7.4.1-pre01, )",
"Mapster.EFCore": "[5.1.2-pre01, )",
"Microsoft.EntityFrameworkCore": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Abstractions": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Relational": "[9.0.0-preview.3.24172.4, )"
Expand Down Expand Up @@ -1624,7 +1608,6 @@
"dependencies": {
"Edelstein.Common.Database": "[1.0.0, )",
"Edelstein.Protocol.Services.Migration": "[1.0.0, )",
"Mapster": "[7.4.1-pre01, )",
"Microsoft.EntityFrameworkCore": "[9.0.0-preview.3.24172.4, )"
}
},
Expand All @@ -1640,7 +1623,6 @@
"dependencies": {
"Edelstein.Common.Database": "[1.0.0, )",
"Edelstein.Protocol.Services.Session": "[1.0.0, )",
"Mapster": "[7.4.1-pre01, )",
"Microsoft.EntityFrameworkCore": "[9.0.0-preview.3.24172.4, )"
}
},
Expand Down Expand Up @@ -1725,6 +1707,15 @@
"edelstein.protocol.utilities": {
"type": "Project"
},
"AutoMapper": {
"type": "CentralTransitive",
"requested": "[13.0.1, )",
"resolved": "13.0.1",
"contentHash": "/Fx1SbJ16qS7dU4i604Sle+U9VLX+WSNVJggk6MupKVkYvvBm4XqYaeFuf67diHefHKHs50uQIS2YEDFhPCakQ==",
"dependencies": {
"Microsoft.Extensions.Options": "6.0.0"
}
},
"BCrypt.Net-Next": {
"type": "CentralTransitive",
"requested": "[4.0.3, )",
Expand Down Expand Up @@ -1779,25 +1770,6 @@
"resolved": "1.6.0",
"contentHash": "qbQ+kukflXfbsLbqZtMfqLPPo0oUgKISLt7ylqrEt3PbIfFVci2dlU9X94k7B++g2h7Rp4oOhL1aY2VCXovzag=="
},
"Mapster": {
"type": "CentralTransitive",
"requested": "[7.4.1-pre01, )",
"resolved": "7.4.1-pre01",
"contentHash": "b7YEDoh4nuODGF7wUjgkxA3bTLLt7TxfPkKiFQTgCrNYHem1VVaJyXgsG9RVeQQ44+hoo69IfqENNKn0ox9ddg==",
"dependencies": {
"Mapster.Core": "1.2.2-pre01"
}
},
"Mapster.EFCore": {
"type": "CentralTransitive",
"requested": "[5.1.2-pre01, )",
"resolved": "5.1.2-pre01",
"contentHash": "cuXP2ZxOhWrWK12eA+pxY9bVNW/NG+Afl0Di05NwOyO9PGJGPzEOKe59tuMdycNfEyBO4iFvp4GyaETwvTh2eg==",
"dependencies": {
"Mapster": "7.4.1-pre01",
"Microsoft.EntityFrameworkCore": "6.0.1"
}
},
"McMaster.NETCore.Plugins": {
"type": "CentralTransitive",
"requested": "[1.4.0, )",
Expand Down
36 changes: 10 additions & 26 deletions src/common/Edelstein.Common.Database.Pgsql/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@
"resolved": "2.14.1",
"contentHash": "lQKvtaTDOXnoVJ20ibTuSIOf2i0uO0MPbDhd1jm238I+U/2ZnRENj0cktKZhtchBMtCUSRQ5v4xBCUbKNmyVMw=="
},
"Mapster.Core": {
"type": "Transitive",
"resolved": "1.2.2-pre01",
"contentHash": "FuNCfTHytW9yeSuGHZ9f8u4cgbzhPL0GqoypA4LD99m0zkafs73IcaMxmbUtYjRThof+Z+jcEQ/suVYTkMpTkA=="
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "7.0.0",
Expand Down Expand Up @@ -1300,12 +1295,11 @@
"edelstein.common.database": {
"type": "Project",
"dependencies": {
"AutoMapper": "[13.0.1, )",
"Edelstein.Common.Gameplay": "[1.0.0, )",
"Edelstein.Common.Services.Auth": "[1.0.0, )",
"Edelstein.Protocol.Services.Migration": "[1.0.0, )",
"Edelstein.Protocol.Services.Session": "[1.0.0, )",
"Mapster": "[7.4.1-pre01, )",
"Mapster.EFCore": "[5.1.2-pre01, )",
"Microsoft.EntityFrameworkCore": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Abstractions": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Relational": "[9.0.0-preview.3.24172.4, )"
Expand Down Expand Up @@ -1397,6 +1391,15 @@
"edelstein.protocol.utilities": {
"type": "Project"
},
"AutoMapper": {
"type": "CentralTransitive",
"requested": "[13.0.1, )",
"resolved": "13.0.1",
"contentHash": "/Fx1SbJ16qS7dU4i604Sle+U9VLX+WSNVJggk6MupKVkYvvBm4XqYaeFuf67diHefHKHs50uQIS2YEDFhPCakQ==",
"dependencies": {
"Microsoft.Extensions.Options": "6.0.0"
}
},
"BCrypt.Net-Next": {
"type": "CentralTransitive",
"requested": "[4.0.3, )",
Expand Down Expand Up @@ -1451,25 +1454,6 @@
"resolved": "1.6.0",
"contentHash": "qbQ+kukflXfbsLbqZtMfqLPPo0oUgKISLt7ylqrEt3PbIfFVci2dlU9X94k7B++g2h7Rp4oOhL1aY2VCXovzag=="
},
"Mapster": {
"type": "CentralTransitive",
"requested": "[7.4.1-pre01, )",
"resolved": "7.4.1-pre01",
"contentHash": "b7YEDoh4nuODGF7wUjgkxA3bTLLt7TxfPkKiFQTgCrNYHem1VVaJyXgsG9RVeQQ44+hoo69IfqENNKn0ox9ddg==",
"dependencies": {
"Mapster.Core": "1.2.2-pre01"
}
},
"Mapster.EFCore": {
"type": "CentralTransitive",
"requested": "[5.1.2-pre01, )",
"resolved": "5.1.2-pre01",
"contentHash": "cuXP2ZxOhWrWK12eA+pxY9bVNW/NG+Afl0Di05NwOyO9PGJGPzEOKe59tuMdycNfEyBO4iFvp4GyaETwvTh2eg==",
"dependencies": {
"Mapster": "7.4.1-pre01",
"Microsoft.EntityFrameworkCore": "6.0.1"
}
},
"Microsoft.EntityFrameworkCore.Abstractions": {
"type": "CentralTransitive",
"requested": "[9.0.0-preview.3.24172.4, )",
Expand Down
36 changes: 10 additions & 26 deletions src/common/Edelstein.Common.Database.Sqlite/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@
"resolved": "2.14.1",
"contentHash": "lQKvtaTDOXnoVJ20ibTuSIOf2i0uO0MPbDhd1jm238I+U/2ZnRENj0cktKZhtchBMtCUSRQ5v4xBCUbKNmyVMw=="
},
"Mapster.Core": {
"type": "Transitive",
"resolved": "1.2.2-pre01",
"contentHash": "FuNCfTHytW9yeSuGHZ9f8u4cgbzhPL0GqoypA4LD99m0zkafs73IcaMxmbUtYjRThof+Z+jcEQ/suVYTkMpTkA=="
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "7.0.0",
Expand Down Expand Up @@ -1338,12 +1333,11 @@
"edelstein.common.database": {
"type": "Project",
"dependencies": {
"AutoMapper": "[13.0.1, )",
"Edelstein.Common.Gameplay": "[1.0.0, )",
"Edelstein.Common.Services.Auth": "[1.0.0, )",
"Edelstein.Protocol.Services.Migration": "[1.0.0, )",
"Edelstein.Protocol.Services.Session": "[1.0.0, )",
"Mapster": "[7.4.1-pre01, )",
"Mapster.EFCore": "[5.1.2-pre01, )",
"Microsoft.EntityFrameworkCore": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Abstractions": "[9.0.0-preview.3.24172.4, )",
"Microsoft.EntityFrameworkCore.Relational": "[9.0.0-preview.3.24172.4, )"
Expand Down Expand Up @@ -1435,6 +1429,15 @@
"edelstein.protocol.utilities": {
"type": "Project"
},
"AutoMapper": {
"type": "CentralTransitive",
"requested": "[13.0.1, )",
"resolved": "13.0.1",
"contentHash": "/Fx1SbJ16qS7dU4i604Sle+U9VLX+WSNVJggk6MupKVkYvvBm4XqYaeFuf67diHefHKHs50uQIS2YEDFhPCakQ==",
"dependencies": {
"Microsoft.Extensions.Options": "6.0.0"
}
},
"BCrypt.Net-Next": {
"type": "CentralTransitive",
"requested": "[4.0.3, )",
Expand Down Expand Up @@ -1489,25 +1492,6 @@
"resolved": "1.6.0",
"contentHash": "qbQ+kukflXfbsLbqZtMfqLPPo0oUgKISLt7ylqrEt3PbIfFVci2dlU9X94k7B++g2h7Rp4oOhL1aY2VCXovzag=="
},
"Mapster": {
"type": "CentralTransitive",
"requested": "[7.4.1-pre01, )",
"resolved": "7.4.1-pre01",
"contentHash": "b7YEDoh4nuODGF7wUjgkxA3bTLLt7TxfPkKiFQTgCrNYHem1VVaJyXgsG9RVeQQ44+hoo69IfqENNKn0ox9ddg==",
"dependencies": {
"Mapster.Core": "1.2.2-pre01"
}
},
"Mapster.EFCore": {
"type": "CentralTransitive",
"requested": "[5.1.2-pre01, )",
"resolved": "5.1.2-pre01",
"contentHash": "cuXP2ZxOhWrWK12eA+pxY9bVNW/NG+Afl0Di05NwOyO9PGJGPzEOKe59tuMdycNfEyBO4iFvp4GyaETwvTh2eg==",
"dependencies": {
"Mapster": "7.4.1-pre01",
"Microsoft.EntityFrameworkCore": "6.0.1"
}
},
"Microsoft.EntityFrameworkCore.Abstractions": {
"type": "CentralTransitive",
"requested": "[9.0.0-preview.3.24172.4, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<ProjectReference Include="..\Edelstein.Common.Services.Auth\Edelstein.Common.Services.Auth.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Mapster" />
<PackageReference Include="Mapster.EFCore" />
<PackageReference Include="AutoMapper" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Protocol.Gameplay.Entities;
using MapsterMapper;
using Microsoft.EntityFrameworkCore;

namespace Edelstein.Common.Database.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Protocol.Gameplay.Entities;
using MapsterMapper;
using Microsoft.EntityFrameworkCore;

namespace Edelstein.Common.Database.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Protocol.Gameplay.Entities;
using MapsterMapper;
using Microsoft.EntityFrameworkCore;

namespace Edelstein.Common.Database.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Protocol.Utilities.Repositories;
using MapsterMapper;
using Microsoft.EntityFrameworkCore;

namespace Edelstein.Common.Database.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AutoMapper;
using Edelstein.Common.Services.Auth;
using MapsterMapper;
using Microsoft.EntityFrameworkCore;

namespace Edelstein.Common.Database.Entities.Services.Auth;
Expand Down
Loading

0 comments on commit 3cbe1af

Please sign in to comment.