Added avalonia integration and remote proof of concept
This commit is contained in:
parent
775080a178
commit
4a0973b681
23 changed files with 2043 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using Catalog.Communication.DependencyInjection;
|
||||
using ImageCatalog;
|
||||
using ImageCatalog_2.Services;
|
||||
using MaddoShared;
|
||||
|
|
@ -59,7 +60,7 @@ static class Program
|
|||
}
|
||||
#endif
|
||||
|
||||
public static IServiceProvider ServiceProvider { get; private set; }
|
||||
public static IServiceProvider ServiceProvider { get; private set; } = default!;
|
||||
|
||||
public static Avalonia.AppBuilder BuildAvaloniaApp()
|
||||
=> Avalonia.AppBuilder.Configure<AvaloniaApp>()
|
||||
|
|
@ -172,6 +173,17 @@ static class Program
|
|||
services.AddSingleton(new ParametriSetup(userPrefsPath));
|
||||
services.AddSingleton<PicSettings>();
|
||||
|
||||
services.AddCatalogCommunication(options =>
|
||||
{
|
||||
options.BaseUri = new Uri("https://www.regalamiunsorriso.it/");
|
||||
options.AdminPageBasePath = "admin/pg_RUS";
|
||||
options.RequestTimeout = TimeSpan.FromSeconds(30);
|
||||
options.RetryCount = 2;
|
||||
options.RetryBaseDelay = TimeSpan.FromMilliseconds(250);
|
||||
});
|
||||
|
||||
services.AddTransient<AvaloniaMainWindow>();
|
||||
|
||||
#if WINDOWS
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<ImageCatalog_2.MainWindow>();
|
||||
|
|
@ -199,7 +211,7 @@ public static class ConsoleLoggerExtensions
|
|||
}
|
||||
public sealed class CustomLoggingFormatter : ConsoleFormatter, IDisposable
|
||||
{
|
||||
private readonly IDisposable _optionsReloadToken;
|
||||
private readonly IDisposable? _optionsReloadToken;
|
||||
private ConsoleFormatterOptions _formatterOptions;
|
||||
public CustomLoggingFormatter(IOptionsMonitor<ConsoleFormatterOptions> options)
|
||||
// Case insensitive
|
||||
|
|
@ -214,6 +226,11 @@ public sealed class CustomLoggingFormatter : ConsoleFormatter, IDisposable
|
|||
IExternalScopeProvider? scopeProvider,
|
||||
TextWriter? textWriter)
|
||||
{
|
||||
if (textWriter is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string? message =
|
||||
logEntry.Formatter?.Invoke(
|
||||
logEntry.State, logEntry.Exception);
|
||||
|
|
@ -223,7 +240,20 @@ public sealed class CustomLoggingFormatter : ConsoleFormatter, IDisposable
|
|||
return;
|
||||
}
|
||||
|
||||
textWriter.WriteLine($"{message}");
|
||||
var timestamp = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
var level = logEntry.LogLevel.ToString().ToUpperInvariant();
|
||||
var category = logEntry.Category ?? "App";
|
||||
|
||||
var line = $"{timestamp} [{level}] {category}: {message}";
|
||||
textWriter.WriteLine(line);
|
||||
System.Diagnostics.Debug.WriteLine(line);
|
||||
|
||||
if (logEntry.Exception is not null)
|
||||
{
|
||||
var exceptionText = logEntry.Exception.ToString();
|
||||
textWriter.WriteLine(exceptionText);
|
||||
System.Diagnostics.Debug.WriteLine(exceptionText);
|
||||
}
|
||||
}
|
||||
public void Dispose() => _optionsReloadToken?.Dispose();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue