|
|
|
@ -8,6 +8,16 @@ namespace Microsoft.Extensions.DependencyInjection |
|
|
|
{ |
|
|
|
public static class ServiceCollectionCommonExtensions |
|
|
|
{ |
|
|
|
public static bool IsAdded<T>(this IServiceCollection services) |
|
|
|
{ |
|
|
|
return services.IsAdded(typeof(T)); |
|
|
|
} |
|
|
|
|
|
|
|
public static bool IsAdded(this IServiceCollection services, Type type) |
|
|
|
{ |
|
|
|
return services.Any(d => d.ServiceType == type); |
|
|
|
} |
|
|
|
|
|
|
|
public static T GetSingletonInstanceOrNull<T>(this IServiceCollection services) |
|
|
|
{ |
|
|
|
return (T)services |
|
|
|
|