JiShe.IOT.Admin/src/JiShe.IoT.Domain/IoTDomainService.cs
2025-05-27 14:27:50 +08:00

36 lines
1.3 KiB
C#

using Volo.Abp.EventBus.Local;
namespace JiShe.IoT
{
public abstract class IoTDomainService : DomainService
{
protected Type ObjectMapperContext { get; set; }
/// <summary>
/// 工作单元管理器
/// </summary>
protected IUnitOfWorkManager UnitOfWorkManager =>
LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>();
/// <summary>
/// 领域事件总线
/// </summary>
protected ILocalEventBus LocalEventBus =>
LazyServiceProvider.LazyGetRequiredService<ILocalEventBus>();
/// <summary>
/// 分布式事件总线
/// </summary>
protected IDistributedEventBus DistributedEventBus =>
LazyServiceProvider.LazyGetRequiredService<IDistributedEventBus>();
/// <summary>
/// 对象映射器
/// </summary>
protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(
provider =>
ObjectMapperContext == null
? provider.GetRequiredService<IObjectMapper>()
: (IObjectMapper)provider.GetRequiredService(
typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));
}
}