// // ServiceCollectionExtensions.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 Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using NosSmooth.Core.Client; using NosSmooth.Core.Extensions; using NosSmooth.LocalBinding.Extensions; using NosSmooth.LocalClient.CommandHandlers.Attack; using NosSmooth.LocalClient.CommandHandlers.Walk; namespace NosSmooth.LocalClient.Extensions; /// /// Contains extension methods for . /// public static class ServiceCollectionExtensions { /// /// Adds along with all core dependencies. /// /// The service collection. /// The collection. public static IServiceCollection AddLocalClient(this IServiceCollection serviceCollection) { serviceCollection.AddNostaleCore(); serviceCollection.AddNostaleBindings(); serviceCollection .AddSingleton() .AddTakeControlCommand() .AddCommandHandler() .AddCommandHandler() .AddCommandHandler(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(p => p.GetRequiredService()); return serviceCollection; } /// /// Adds packet interceptor. /// /// The service collection. /// The type of the interceptor. /// The collection. public static IServiceCollection AddPacketInterceptor(this IServiceCollection serviceCollection) where TInterceptor : class, IPacketInterceptor { return serviceCollection.AddSingleton(); } }