// // Program.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using FileClient.Responders; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using NosSmooth.Core.Client; using NosSmooth.Core.Commands; using NosSmooth.Core.Extensions; using NosSmooth.Core.Packets; using NosSmooth.Data.Abstractions.Language; using NosSmooth.Data.NOSFiles.Extensions; using NosSmooth.Data.NOSFiles.Options; using NosSmooth.Game.Extensions; using NosSmooth.Packets; using NosSmooth.PacketSerializer; namespace FileClient; /// /// An entrypoint class. /// public static class Program { // TODO: create console hosting. /// /// An entrypoint method. /// /// The command line arguments. /// A representing the asynchronous operation. public static async Task Main(string[] args) { await using FileStream stream = File.OpenRead(string.Join(' ', args)); await CreateHost(stream).RunAsync(); } private static IHost CreateHost(Stream fileStream) { return Host.CreateDefaultBuilder() .ConfigureServices(coll => { coll.AddHostedService(); coll.AddManagedNostaleCore() .AddNostaleGame() .AddNostaleDataFiles() .AddPacketResponder() .Configure(o => o.Language = Language.Cz) .Configure(o => o.SupportedLanguages = new[] { Language.Cz }); coll.AddSingleton(p => new Client( fileStream, p.GetRequiredService(), p.GetRequiredService(), p.GetRequiredService>() )); }) .UseConsoleLifetime() .Build(); } }