chore: reformat & cleanup
All checks were successful
Test if Server can be built / build-server (push) Successful in 24s

This commit is contained in:
Timothy Schenk 2023-08-14 21:30:32 +02:00
parent 010f05c565
commit f802dcf2a3
5 changed files with 24 additions and 26 deletions

View file

@ -2,8 +2,6 @@
public class Account
{
public Guid Id { get; set; }
public Account(string username, byte[] password, string email, byte permissionLevel, byte[] salt)
{
this.Username = username;
@ -13,6 +11,8 @@ public class Account
this.Salt = salt;
}
public Guid Id { get; set; }
public string Username { get; set; }
public byte[] Password { get; set; }
public string Email { get; set; }

View file

@ -7,8 +7,8 @@ using Microsoft.Extensions.Logging;
public class WonderkingContext : DbContext
{
private readonly ILoggerFactory loggerFactory;
private readonly IConfiguration configuration;
private readonly ILoggerFactory loggerFactory;
public WonderkingContext(ILoggerFactory loggerFactory, IConfiguration configuration)
{
@ -16,6 +16,8 @@ public class WonderkingContext : DbContext
this.configuration = configuration;
}
public DbSet<Account> Accounts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
optionsBuilder
.UseNpgsql(
@ -30,6 +32,4 @@ public class WonderkingContext : DbContext
builder.Property(b => b.Salt).HasColumnType("bytea");
builder.HasKey(b => b.Id);
});
public DbSet<Account> Accounts { get; set; }
}

View file

@ -3,7 +3,6 @@ using System.Net;
using System.Reflection;
using MassTransit;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@ -11,22 +10,20 @@ using Server.DB;
using Server.Services;
var builder = Host.CreateApplicationBuilder();
var configurationRoot = builder.Configuration.AddJsonFile("settings.json", false, true)
.AddEnvironmentVariables().Build();
builder.Services.AddLogging();
builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Debug);
builder.Logging.AddFile("Logs/Server-{Date}.json.log", LogLevel.Debug, isJson: true);
builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Trace);
builder.Logging.AddFile("Logs/Server-{Date}.json.log", LogLevel.Trace, isJson: true);
builder.Services.AddEntityFrameworkNpgsql();
builder.Services.AddDbContext<WonderkingContext>();
builder.Services.AddSingleton<PacketDistributorService>();
builder.Services.AddHostedService<PacketDistributorService>(provider =>
builder.Services.AddHostedService(provider =>
provider.GetService<PacketDistributorService>() ?? throw new InvalidOperationException());
builder.Services.AddMassTransit(x =>
{
x.UsingInMemory((context, configurator) => configurator.ConfigureEndpoints(context));
x.AddMediator(cfg => cfg.AddConsumers(Assembly.GetExecutingAssembly()));
});
builder.Services.AddHostedService<WonderkingAuthServer>(provider => new WonderkingAuthServer(IPAddress.Any, 10001,
builder.Services.AddHostedService(provider => new WonderkingAuthServer(IPAddress.Any, 10001,
provider.GetService<ILogger<WonderkingAuthServer>>() ?? throw new InvalidOperationException(),
provider.GetService<IServiceProvider>() ?? throw new InvalidOperationException()));

View file

@ -18,27 +18,27 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNext" Version="4.13.1" />
<PackageReference Include="DotNext.IO" Version="4.13.1" />
<PackageReference Include="DotNext.Metaprogramming" Version="4.13.1" />
<PackageReference Include="DotNext.Reflection" Version="4.9.0" />
<PackageReference Include="DotNext.Threading" Version="4.13.1" />
<PackageReference Include="DotNext.Unsafe" Version="4.13.1" />
<PackageReference Include="DotNext" Version="4.13.1"/>
<PackageReference Include="DotNext.IO" Version="4.13.1"/>
<PackageReference Include="DotNext.Metaprogramming" Version="4.13.1"/>
<PackageReference Include="DotNext.Reflection" Version="4.9.0"/>
<PackageReference Include="DotNext.Threading" Version="4.13.1"/>
<PackageReference Include="DotNext.Unsafe" Version="4.13.1"/>
<PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0"/>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" />
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/>
<PackageReference Include="MassTransit" Version="8.0.16"/>
<PackageReference Include="MassTransit.Analyzers" Version="8.0.16">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -56,7 +56,7 @@
</PackageReference>
<PackageReference Include="NetCoreServer" Version="7.0.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4"/>
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View file

@ -17,13 +17,14 @@ using static DotNext.Linq.Expressions.ExpressionBuilder;
public class PacketDistributorService : IHostedService
{
private readonly ConcurrentQueue<RawPacket> concurrentQueue;
private readonly ILogger<PacketDistributorService> logger;
private readonly ConcurrentDictionary<OperationCode, object> packetHandlersInstantiation;
private readonly
ImmutableDictionary<OperationCode,
Func<byte[], IPacket>> deserializationMap;
private readonly ILogger<PacketDistributorService> logger;
private readonly ConcurrentDictionary<OperationCode, object> packetHandlersInstantiation;
private readonly IServiceProvider serviceProvider;
public PacketDistributorService(ILogger<PacketDistributorService> logger, IServiceProvider serviceProvider)