mirror of
https://github.com/ryzij/AMessanger-Avalonia-Client.git
synced 2026-09-18 11:43:21 +00:00
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Avalonia;
|
|
using System;
|
|
using AMessanger.ViewModels;
|
|
using AMessanger.Services;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace AMessanger;
|
|
|
|
sealed class Program
|
|
{
|
|
public static IServiceProvider Services { get; private set; } = null!;
|
|
|
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
|
// yet and stuff might break.
|
|
[STAThread]
|
|
public static void Main(string[] args)
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
services.AddSingleton(p =>
|
|
{
|
|
var url = File
|
|
.ReadAllLines("ConnectionUrl")
|
|
.First(l => !string.IsNullOrWhiteSpace(l)
|
|
&& !l.TrimStart().StartsWith('#'));
|
|
|
|
var chat = new ChatService(url);
|
|
chat.ConnectAsync();
|
|
|
|
return chat;
|
|
});
|
|
|
|
// ViewModels
|
|
services.AddTransient<MainViewModel>();
|
|
|
|
Services = services.BuildServiceProvider();
|
|
|
|
BuildAvaloniaApp()
|
|
.StartWithClassicDesktopLifetime(args);
|
|
}
|
|
|
|
// Avalonia configuration, don't remove; also used by visual designer.
|
|
public static AppBuilder BuildAvaloniaApp()
|
|
=> AppBuilder.Configure<App>()
|
|
.UsePlatformDetect()
|
|
#if DEBUG
|
|
.WithDeveloperTools()
|
|
#endif
|
|
.WithInterFont()
|
|
.LogToTrace();
|
|
}
|