Made moonlight able to compile and somehwat run with MoonCore.Blazor and the new logging system

This commit is contained in:
Marcel Baumgartner
2024-06-22 11:28:58 +02:00
parent 2060b9140f
commit 42e9f18fb6
102 changed files with 909 additions and 798 deletions

View File

@@ -1,12 +1,21 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using MoonCore.Attributes;
using MoonCore.Helpers;
namespace Moonlight.Core.Helpers;
public static class HostSystemHelper
[Singleton]
public class HostSystemHelper
{
public static Task<string> GetOsName()
private readonly ILogger<HostSystemHelper> Logger;
public HostSystemHelper(ILogger<HostSystemHelper> logger)
{
Logger = logger;
}
public Task<string> GetOsName()
{
try
{
@@ -48,21 +57,20 @@ public static class HostSystemHelper
}
catch (Exception e)
{
Logger.Warn("Error retrieving os information");
Logger.Warn(e);
Logger.LogWarning("Error retrieving os information: {e}", e);
return Task.FromResult("N/A");
}
}
public static Task<long> GetMemoryUsage()
public Task<long> GetMemoryUsage()
{
var process = Process.GetCurrentProcess();
var bytes = process.PrivateMemorySize64;
return Task.FromResult(bytes);
}
public static Task<int> GetCpuUsage()
public Task<int> GetCpuUsage()
{
var process = Process.GetCurrentProcess();
var cpuTime = process.TotalProcessorTime;