Abp模块
abp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.4 KiB

using Microsoft.Extensions.DependencyInjection;
using Sanhe.Abp.IdGenerator;
using Sanhe.Abp.RealTime;
using System;
using System.Collections.Generic;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
namespace Sanhe.Abp.Notifications;
// TODO: 需要重命名 AbpNotificationsModule
[DependsOn(
typeof(AbpBackgroundWorkersModule),
typeof(AbpBackgroundJobsAbstractionsModule),
typeof(AbpIdGeneratorModule),
typeof(AbpJsonModule),
typeof(AbpRealTimeModule))]
public class AbpNotificationsModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
AutoAddDefinitionProviders(context.Services);
}
private void AutoAddDefinitionProviders(IServiceCollection services)
{
var definitionProviders = new List<Type>();
services.OnRegistred(context =>
{
if (typeof(INotificationDefinitionProvider).IsAssignableFrom(context.ImplementationType))
{
definitionProviders.Add(context.ImplementationType);
}
});
var preActions = services.GetPreConfigureActions<AbpNotificationsOptions>();
Configure<AbpNotificationsOptions>(options =>
{
preActions.Configure(options);
options.DefinitionProviders.AddIfNotContains(definitionProviders);
});
}
}