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

Loading…
Cancel
Save