public static void TryAddSingleton <TService>(this ICoconaLiteServiceCollection services, Func <IServiceProvider, TService> factory) { if (services.All(x => x.ServiceType != typeof(TService))) { services.AddSingleton <TService>(factory); } }
public static void TryAddSingleton <TService>(this ICoconaLiteServiceCollection services, TService instance) { if (services.All(x => x.ServiceType != typeof(TService))) { services.AddSingleton <TService>(instance); } }
public static void TryAddSingleton <TService, TImplementation>(this ICoconaLiteServiceCollection services) where TImplementation : TService { if (services.All(x => x.ServiceType != typeof(TService))) { services.AddSingleton <TService, TImplementation>(); } }
public static void AddSingleton <TService>(this ICoconaLiteServiceCollection services, TService instance) { services.AddSingleton <TService>(_ => instance); }