Browse Source

Refactor GetHostingEnvironment

pull/11014/head
Yunus Emre Kalkan 5 years ago
parent
commit
c02a2844ed
  1. 6
      framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs

6
framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs

@ -8,7 +8,9 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static IWebHostEnvironment GetHostingEnvironment(this IServiceCollection services)
{
if (!services.Any(d => d.ServiceType == typeof(IWebHostEnvironment)))
var hostingEnvironment = services.GetSingletonInstanceOrNull<IWebHostEnvironment>();
if (hostingEnvironment == null)
{
return new EmptyHostingEnvironment()
{
@ -16,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection
};
}
return services.GetSingletonInstance<IWebHostEnvironment>();
return hostingEnvironment;
}
}
}

Loading…
Cancel
Save