From b4d04008459d2a5fc7b2c95e86dc3686d5595e94 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Thu, 3 Mar 2022 13:47:37 +0200 Subject: [PATCH] SystemRegistry.GetVersion --- .../Queries/System/GetSystemVersion.cs | 7 ++----- .../Utils/SystemRegistry.cs | 10 ++++++++++ src/server/ProxmoxConnector.Server/Program.cs | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/server/ProxmoxConnector.Server.Application/Utils/SystemRegistry.cs diff --git a/src/server/ProxmoxConnector.Server.Application/Queries/System/GetSystemVersion.cs b/src/server/ProxmoxConnector.Server.Application/Queries/System/GetSystemVersion.cs index 68c5f0c..d587a60 100644 --- a/src/server/ProxmoxConnector.Server.Application/Queries/System/GetSystemVersion.cs +++ b/src/server/ProxmoxConnector.Server.Application/Queries/System/GetSystemVersion.cs @@ -1,5 +1,5 @@ using MediatR; -using System.Reflection; +using ProxmoxConnector.Server.Application.Utils; using System.Threading; using System.Threading.Tasks; @@ -27,13 +27,10 @@ namespace ProxmoxConnector.Server.Application.Queries.System public async Task Handle(Query request, CancellationToken cancellationToken) { - var version = GetVersion(); + var version = SystemRegistry.GetVersion(); var result = new Model { Version = version }; return await Task.FromResult(result); } - - private string GetVersion() => - Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; } } } diff --git a/src/server/ProxmoxConnector.Server.Application/Utils/SystemRegistry.cs b/src/server/ProxmoxConnector.Server.Application/Utils/SystemRegistry.cs new file mode 100644 index 0000000..33ef887 --- /dev/null +++ b/src/server/ProxmoxConnector.Server.Application/Utils/SystemRegistry.cs @@ -0,0 +1,10 @@ +using System.Reflection; + +namespace ProxmoxConnector.Server.Application.Utils +{ + public static class SystemRegistry + { + public static string GetVersion() => + Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; + } +} diff --git a/src/server/ProxmoxConnector.Server/Program.cs b/src/server/ProxmoxConnector.Server/Program.cs index 7ffa91d..c0bae3e 100644 --- a/src/server/ProxmoxConnector.Server/Program.cs +++ b/src/server/ProxmoxConnector.Server/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using ProxmoxConnector.Server.Application.Services.Environment; +using ProxmoxConnector.Server.Application.Utils; using Serilog; using Serilog.Core; using Serilog.Events; @@ -9,6 +10,7 @@ using System; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; namespace ProxmoxConnector.Server { @@ -52,7 +54,7 @@ namespace ProxmoxConnector.Server try { var urls = configuration.GetValue("urls"); - Log.Information("Starting Proxmox connector..."); + Log.Information($"Starting Proxmox connector {SystemRegistry.GetVersion()}..."); Log.Information($"API listening on {urls}"); Log.Information($"Workspace configured at '{workspace}' path"); Console.WriteLine("Application started. Press Ctrl+C to shut down.");