Browse Source

Merge pull request #11038 from abpframework/auto-merge/rel-5-0/736

Merge branch dev with rel-5.0
pull/11043/head
maliming 5 years ago
committed by GitHub
parent
commit
fbd6331b6c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/AbpAspNetCoreServiceCollectionExtensions.cs
  2. 19
      framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs
  3. 2
      test/DistEvents/DistDemoApp.Shared/DistDemoApp.Shared.csproj
  4. 10
      test/DistEvents/DistDemoApp.Shared/DistDemoAppSharedModule.cs

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

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Hosting; using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -6,6 +8,16 @@ public static class AbpAspNetCoreServiceCollectionExtensions
{ {
public static IWebHostEnvironment GetHostingEnvironment(this IServiceCollection services) public static IWebHostEnvironment GetHostingEnvironment(this IServiceCollection services)
{ {
return services.GetSingletonInstance<IWebHostEnvironment>(); var hostingEnvironment = services.GetSingletonInstanceOrNull<IWebHostEnvironment>();
if (hostingEnvironment == null)
{
return new EmptyHostingEnvironment()
{
EnvironmentName = Environments.Development
};
}
return hostingEnvironment;
} }
} }

19
framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;
namespace Microsoft.Extensions.DependencyInjection;
internal class EmptyHostingEnvironment : IWebHostEnvironment
{
public string EnvironmentName { get; set; }
public string ApplicationName { get; set; }
public string WebRootPath { get; set; }
public IFileProvider WebRootFileProvider { get; set; }
public string ContentRootPath { get; set; }
public IFileProvider ContentRootFileProvider { get; set; }
}

2
test/DistEvents/DistDemoApp.Shared/DistDemoApp.Shared.csproj

@ -17,7 +17,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" /> <ProjectReference Include="..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.EventBus.Boxes\Volo.Abp.EventBus.Boxes.csproj" /> <ProjectReference Include="..\..\..\framework\src\Volo.Abp.EventBus\Volo.Abp.EventBus.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

10
test/DistEvents/DistDemoApp.Shared/DistDemoAppSharedModule.cs

@ -5,7 +5,7 @@ using StackExchange.Redis;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.Domain; using Volo.Abp.Domain;
using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Boxes; using Volo.Abp.EventBus;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace DistDemoApp namespace DistDemoApp
@ -13,8 +13,8 @@ namespace DistDemoApp
[DependsOn( [DependsOn(
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpDddDomainModule), typeof(AbpDddDomainModule),
typeof(AbpEventBusBoxesModule) typeof(AbpEventBusModule)
)] )]
public class DistDemoAppSharedModule : AbpModule public class DistDemoAppSharedModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
@ -28,7 +28,7 @@ namespace DistDemoApp
options.EtoMappings.Add<TodoItem, TodoItemEto>(); options.EtoMappings.Add<TodoItem, TodoItemEto>();
options.AutoEventSelectors.Add<TodoItem>(); options.AutoEventSelectors.Add<TodoItem>();
}); });
context.Services.AddSingleton<IDistributedLockProvider>(sp => context.Services.AddSingleton<IDistributedLockProvider>(sp =>
{ {
var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
@ -36,4 +36,4 @@ namespace DistDemoApp
}); });
} }
} }
} }

Loading…
Cancel
Save