mirror of
https://github.com/ryzij/AMessanger-Avalonia-Client.git
synced 2026-09-18 20:13:20 +00:00
First commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user