DiscordChatExporter/DiscordChatExporter.Gui/Program.cs

54 lines
1.6 KiB
C#
Raw Normal View History

2024-04-26 21:17:46 -04:00
using System;
using System.Reflection;
using Avalonia;
using DiscordChatExporter.Gui.Utils;
namespace DiscordChatExporter.Gui;
public static class Program
{
2024-05-31 17:36:24 -04:00
private static Assembly Assembly { get; } = Assembly.GetExecutingAssembly();
2024-04-26 21:17:46 -04:00
2024-05-31 17:36:24 -04:00
public static string Name { get; } = Assembly.GetName().Name ?? "DiscordChatExporter";
2024-04-26 21:17:46 -04:00
2024-05-31 17:36:24 -04:00
public static Version Version { get; } = Assembly.GetName().Version ?? new Version(0, 0, 0);
2024-04-26 21:17:46 -04:00
public static string VersionString { get; } = Version.ToString(3);
public static bool IsDevelopmentBuild { get; } = Version.Major is <= 0 or >= 999;
2024-04-26 21:17:46 -04:00
public static string ProjectUrl { get; } = "https://github.com/Tyrrrz/DiscordChatExporter";
public static string ProjectReleasesUrl { get; } = $"{ProjectUrl}/releases";
public static string ProjectDocumentationUrl { get; } = ProjectUrl + "/tree/master/.docs";
2024-04-26 21:17:46 -04:00
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace();
[STAThread]
public static int Main(string[] args)
{
// Build and run the app
var builder = BuildAvaloniaApp();
try
{
return builder.StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
if (OperatingSystem.IsWindows())
_ = NativeMethods.Windows.MessageBox(0, ex.ToString(), "Fatal Error", 0x10);
throw;
}
finally
{
// Clean up after application shutdown
if (builder.Instance is IDisposable disposableApp)
disposableApp.Dispose();
}
}
}