SystemRegistry.GetVersion

master
Tudor Stanciu 2022-03-03 13:47:37 +02:00
parent 3267cc8a0d
commit b4d0400845
3 changed files with 15 additions and 6 deletions

View File

@ -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<Model> 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<AssemblyInformationalVersionAttribute>().InformationalVersion;
}
}
}

View File

@ -0,0 +1,10 @@
using System.Reflection;
namespace ProxmoxConnector.Server.Application.Utils
{
public static class SystemRegistry
{
public static string GetVersion() =>
Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
}
}

View File

@ -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<string>("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.");