|
|
|
|
using HighWayIot.Repository.service;
|
|
|
|
|
using HighWayIot.Repository.service.Impl;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.Business
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 注册服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal sealed class RegisterServices
|
|
|
|
|
{
|
|
|
|
|
#region 单例实现
|
|
|
|
|
private static readonly Lazy<RegisterServices> lazy = new Lazy<RegisterServices>(() => new RegisterServices());
|
|
|
|
|
public static RegisterServices Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return lazy.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 接口引用
|
|
|
|
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private RegisterServices()
|
|
|
|
|
{
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
|
|
|
|
|
#region 自动注册服务
|
|
|
|
|
// 自动注册服务
|
|
|
|
|
//Assembly.GetExecutingAssembly()
|
|
|
|
|
// .GetTypes()
|
|
|
|
|
// .Where(t => t.IsClass && !t.IsAbstract)
|
|
|
|
|
// .Where(t => t.GetInterfaces().Any())
|
|
|
|
|
// .ToList()
|
|
|
|
|
// .ForEach(t => services.AddSingleton(t.GetInterfaces().FirstOrDefault(), t));
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
AddSingletonServices(services);
|
|
|
|
|
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 注册服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
private void AddSingletonServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<IBaseBomInfoService, BaseBomInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<IBaseSpaceDetailService, BaseSpaceDetailServiceImpl>();
|
|
|
|
|
services.AddSingleton<IBaseSpaceInfoService, BaseSpaceInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<IExecutePlanInfoService, ExecutePlanInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<IProductPlanInfoService, ProductPlanInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<IRealTaskInfoService, RealTaskInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<ISysUserInfoService, SysUserInfoServiceImpl>();
|
|
|
|
|
services.AddSingleton<IRecordInStoreService, RecordInStoreServiceImpl>();
|
|
|
|
|
services.AddSingleton<IRecordOutStoreService, RecordOutStoreServiceImpl>();
|
|
|
|
|
services.AddSingleton<IRecordProductfinishService, RecordProductfinishServiceImpl>();
|
|
|
|
|
services.AddSingleton<IPrintBarCodeServices, PrintBarCodeServicesImpl>();
|
|
|
|
|
services.AddSingleton<IMaterialCompletionServices, MaterialCompletionServiceImpl>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T GetService<T>()
|
|
|
|
|
{
|
|
|
|
|
var service = _serviceProvider.GetService<T>();
|
|
|
|
|
return service;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|