From f802dcf2a36766378ba1f695cf6377064f00b3b7 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Mon, 14 Aug 2023 21:30:32 +0200 Subject: [PATCH] chore: reformat & cleanup --- Server/DB/Documents/Account.cs | 4 ++-- Server/DB/WonderkingContext.cs | 6 +++--- Server/Program.cs | 11 ++++------ Server/Server.csproj | 24 ++++++++++----------- Server/Services/PacketDistributorService.cs | 5 +++-- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Server/DB/Documents/Account.cs b/Server/DB/Documents/Account.cs index d7f1fef..336db96 100644 --- a/Server/DB/Documents/Account.cs +++ b/Server/DB/Documents/Account.cs @@ -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; } diff --git a/Server/DB/WonderkingContext.cs b/Server/DB/WonderkingContext.cs index a8d1934..23fe41f 100644 --- a/Server/DB/WonderkingContext.cs +++ b/Server/DB/WonderkingContext.cs @@ -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 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 Accounts { get; set; } } diff --git a/Server/Program.cs b/Server/Program.cs index d2e9ce0..a8807c3 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -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(); builder.Services.AddSingleton(); -builder.Services.AddHostedService(provider => +builder.Services.AddHostedService(provider => provider.GetService() ?? throw new InvalidOperationException()); builder.Services.AddMassTransit(x => { x.UsingInMemory((context, configurator) => configurator.ConfigureEndpoints(context)); x.AddMediator(cfg => cfg.AddConsumers(Assembly.GetExecutingAssembly())); }); -builder.Services.AddHostedService(provider => new WonderkingAuthServer(IPAddress.Any, 10001, +builder.Services.AddHostedService(provider => new WonderkingAuthServer(IPAddress.Any, 10001, provider.GetService>() ?? throw new InvalidOperationException(), provider.GetService() ?? throw new InvalidOperationException())); diff --git a/Server/Server.csproj b/Server/Server.csproj index 72beef3..01295aa 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -18,27 +18,27 @@ - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -56,7 +56,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Server/Services/PacketDistributorService.cs b/Server/Services/PacketDistributorService.cs index a1747cc..458f0e8 100644 --- a/Server/Services/PacketDistributorService.cs +++ b/Server/Services/PacketDistributorService.cs @@ -17,13 +17,14 @@ using static DotNext.Linq.Expressions.ExpressionBuilder; public class PacketDistributorService : IHostedService { private readonly ConcurrentQueue concurrentQueue; - private readonly ILogger logger; - private readonly ConcurrentDictionary packetHandlersInstantiation; private readonly ImmutableDictionary> deserializationMap; + private readonly ILogger logger; + private readonly ConcurrentDictionary packetHandlersInstantiation; + private readonly IServiceProvider serviceProvider; public PacketDistributorService(ILogger logger, IServiceProvider serviceProvider)