This commit is contained in:
Wiesław Šoltés 2018-02-19 21:04:58 +01:00
Родитель 4329820740
Коммит c860af3c4d
1 изменённых файлов: 11 добавлений и 24 удалений

Просмотреть файл

@ -7,7 +7,6 @@ using Avalonia;
using Avalonia.Logging.Serilog; using Avalonia.Logging.Serilog;
using Core2D.Avalonia.Modules; using Core2D.Avalonia.Modules;
using Core2D.Interfaces; using Core2D.Interfaces;
using Serilog;
namespace Core2D.Avalonia namespace Core2D.Avalonia
{ {
@ -16,6 +15,15 @@ namespace Core2D.Avalonia
/// </summary> /// </summary>
class Program class Program
{ {
/// <summary>
/// Builds Avalonia app.
/// </summary>
/// <returns>The Avalonia app builder.</returns>
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug();
/// <summary> /// <summary>
/// Program entry point. /// Program entry point.
/// </summary> /// </summary>
@ -24,31 +32,23 @@ namespace Core2D.Avalonia
{ {
try try
{ {
InitializeLogging();
var builder = new ContainerBuilder(); var builder = new ContainerBuilder();
builder.RegisterModule<LocatorModule>(); builder.RegisterModule<LocatorModule>();
builder.RegisterModule<CoreModule>(); builder.RegisterModule<CoreModule>();
builder.RegisterModule<DependenciesModule>(); builder.RegisterModule<DependenciesModule>();
builder.RegisterModule<AppModule>(); builder.RegisterModule<AppModule>();
builder.RegisterModule<ViewModule>(); builder.RegisterModule<ViewModule>();
using (IContainer container = builder.Build()) using (IContainer container = builder.Build())
{ {
using (ILog log = container.Resolve<ILog>()) using (ILog log = container.Resolve<ILog>())
{ {
var app = new App(); var appBuilder = BuildAvaloniaApp().SetupWithoutStarting();
var appBuilder = AppBuilder.Configure(app).UsePlatformDetect(); var app = appBuilder.Instance as App;
appBuilder.SetupWithoutStarting();
var aboutInfo = app.CreateAboutInfo( var aboutInfo = app.CreateAboutInfo(
appBuilder.RuntimePlatform.GetRuntimeInfo(), appBuilder.RuntimePlatform.GetRuntimeInfo(),
appBuilder.WindowingSubsystemName, appBuilder.WindowingSubsystemName,
appBuilder.RenderingSubsystemName); appBuilder.RenderingSubsystemName);
Debug.Write(aboutInfo); Debug.Write(aboutInfo);
app.Start(container.Resolve<IServiceProvider>(), aboutInfo); app.Start(container.Resolve<IServiceProvider>(), aboutInfo);
} }
} }
@ -59,18 +59,5 @@ namespace Core2D.Avalonia
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
} }
} }
/// <summary>
/// Initialize the Serilog logger.
/// </summary>
static void InitializeLogging()
{
#if DEBUG
SerilogLogger.Initialize(new LoggerConfiguration()
.MinimumLevel.Warning()
.WriteTo.Trace(outputTemplate: "{Area}: {Message}")
.CreateLogger());
#endif
}
} }
} }