Removed CommonCore

This commit is contained in:
Matthias Heil
2026-04-05 08:14:33 +02:00
parent 511a5f9f51
commit 149de07b0e
18 changed files with 134 additions and 123 deletions
@@ -4,7 +4,6 @@ using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using AvaloniaSerilogDI.ViewModels;
using AvaloniaSerilogDI.Views;
using Common.Core.Extensions;
using LogViewer.Avalonia;
using LogViewer.Core;
using Microsoft.Extensions.DependencyInjection;
@@ -23,6 +22,22 @@ using System.Threading;
using Icon = MsBox.Avalonia.Enums.Icon;
namespace AvaloniaSerilogDI;
public static class ServicesExtension
{
public static TModel? TryGetService<TModel>(this IServiceProvider serviceProvider) where TModel : class
{
try
{
return (TModel?)serviceProvider.GetService(typeof(TModel));
}
catch (ObjectDisposedException)
{
// ignore as we do not care...
}
return default;
}
}
public partial class App : Application
{
#region Constructors
@@ -75,7 +90,7 @@ public partial class App : Application
{
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.WriteTo.DataStoreLoggerSink( dataStoreProvider: () => Host!.Services.TryGetService<ILogDataStore>()!,formatProvider: CultureInfo.InvariantCulture)
.WriteTo.DataStoreLoggerSink( dataStoreProvider: () => Host?.Services.TryGetService<ILogDataStore>()!,formatProvider: CultureInfo.InvariantCulture)
.CreateLogger();
cfg.ClearProviders().AddSerilog(Log.Logger);
@@ -46,7 +46,6 @@
<ItemGroup>
<ProjectReference Include="..\..\Background Services\RandomLogging.Service\RandomLogging.Service.csproj" />
<ProjectReference Include="..\..\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj" />
<ProjectReference Include="..\..\Core\Common.Core\Common.Core.csproj" />
<ProjectReference Include="..\..\Core\Serilog.Sinks.LogView.Core\Serilog.Sinks.LogView.Core.csproj" />
</ItemGroup>
</Project>
@@ -2,18 +2,16 @@
namespace AvaloniaSerilogDI.ViewModels;
public class MainViewModel : ViewModelBase
public class MainViewModel(LogViewerControlViewModel logViewer) : ViewModelBase
{
#region Constructor
public MainViewModel(LogViewerControlViewModel logViewer)
=> LogViewer = logViewer;
#region Constructor
#endregion
#region Properties
public LogViewerControlViewModel LogViewer { get; }
public LogViewerControlViewModel LogViewer { get; } = logViewer;
#endregion
}