using Ninject; namespace NadekoBot.Extensions; public static class NinjectIKernelExtensions { public static IKernel AddSingleton(this IKernel kernel) { kernel.Bind().ToSelf().InSingletonScope(); return kernel; } public static IKernel AddSingleton(this IKernel kernel) where TImpl : TInterface { kernel.Bind().To().InSingletonScope(); return kernel; } public static IKernel AddSingleton(this IKernel kernel, TImpl obj) => kernel.AddSingleton(obj); public static IKernel AddSingleton(this IKernel kernel, TImpl obj) where TImpl : TInterface { kernel.Bind().ToConstant(obj).InSingletonScope(); return kernel; } public static IKernel AddSingleton( this IKernel kernel, Func factory) where TImpl : TInterface { kernel.Bind().ToMethod(factory).InSingletonScope(); return kernel; } public static IKernel AddSingleton( this IKernel kernel, Func factory) => kernel.AddSingleton(factory); }