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

View file

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

View file

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

View file

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