Browse Source

Merge pull request #337 from colinin/4.4

fix(realtime): realTime module dependencies should be specified
pull/364/head
yx lin 4 years ago
committed by GitHub
parent
commit
d6d3eac127
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/AbpIMModule.cs
  2. 122
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs

23
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/AbpIMModule.cs

@ -1,10 +1,13 @@
using Volo.Abp.EventBus; using LINGYUN.Abp.RealTime;
using Volo.Abp.Modularity; using Volo.Abp.EventBus;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.IM
{ namespace LINGYUN.Abp.IM
[DependsOn(typeof(AbpEventBusModule))] {
public class AbpIMModule : AbpModule [DependsOn(
{ typeof(AbpEventBusModule),
} typeof(AbpRealTimeModule))]
} public class AbpIMModule : AbpModule
{
}
}

122
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs

@ -1,60 +1,62 @@
using LINGYUN.Abp.Notifications.Internal; using LINGYUN.Abp.Notifications.Internal;
using Microsoft.Extensions.DependencyInjection; using LINGYUN.Abp.RealTime;
using Microsoft.Extensions.Options; using Microsoft.Extensions.DependencyInjection;
using System; using Microsoft.Extensions.Options;
using System.Collections.Generic; using System;
using Volo.Abp; using System.Collections.Generic;
using Volo.Abp.BackgroundJobs; using Volo.Abp;
using Volo.Abp.BackgroundWorkers; using Volo.Abp.BackgroundJobs;
using Volo.Abp.Json; using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Modularity; using Volo.Abp.Json;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Notifications
{ namespace LINGYUN.Abp.Notifications
// TODO: 需要重命名 AbpNotificationsModule {
[DependsOn( // TODO: 需要重命名 AbpNotificationsModule
typeof(AbpBackgroundWorkersModule), [DependsOn(
typeof(AbpBackgroundJobsAbstractionsModule), typeof(AbpBackgroundWorkersModule),
typeof(AbpJsonModule))] typeof(AbpBackgroundJobsAbstractionsModule),
public class AbpNotificationModule : AbpModule typeof(AbpJsonModule),
{ typeof(AbpRealTimeModule))]
public class AbpNotificationModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context) {
{
AutoAddDefinitionProviders(context.Services); public override void PreConfigureServices(ServiceConfigurationContext context)
} {
AutoAddDefinitionProviders(context.Services);
public override void OnPostApplicationInitialization(ApplicationInitializationContext context) }
{
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpNotificationCleanupOptions>>().Value; public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
if (options.IsEnabled) {
{ var options = context.ServiceProvider.GetRequiredService<IOptions<AbpNotificationCleanupOptions>>().Value;
context.ServiceProvider if (options.IsEnabled)
.GetRequiredService<IBackgroundWorkerManager>() {
.Add( context.ServiceProvider
context.ServiceProvider .GetRequiredService<IBackgroundWorkerManager>()
.GetRequiredService<NotificationCleanupBackgroundWorker>() .Add(
); context.ServiceProvider
} .GetRequiredService<NotificationCleanupBackgroundWorker>()
} );
}
private static void AutoAddDefinitionProviders(IServiceCollection services) }
{
var definitionProviders = new List<Type>(); private static void AutoAddDefinitionProviders(IServiceCollection services)
{
services.OnRegistred(context => var definitionProviders = new List<Type>();
{
if (typeof(INotificationDefinitionProvider).IsAssignableFrom(context.ImplementationType)) services.OnRegistred(context =>
{ {
definitionProviders.Add(context.ImplementationType); if (typeof(INotificationDefinitionProvider).IsAssignableFrom(context.ImplementationType))
} {
}); definitionProviders.Add(context.ImplementationType);
}
services.Configure<AbpNotificationOptions>(options => });
{
services.ExecutePreConfiguredActions(options); services.Configure<AbpNotificationOptions>(options =>
options.DefinitionProviders.AddIfNotContains(definitionProviders); {
}); services.ExecutePreConfiguredActions(options);
} options.DefinitionProviders.AddIfNotContains(definitionProviders);
} });
} }
}
}

Loading…
Cancel
Save