Update
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.Package;
|
||||
using FMSMicroservice.Protobuf.Protos.FileInfo;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace BackOffice.BFF.Infrastructure.Services;
|
||||
|
||||
public class ApplicationContractContext : IApplicationContractContext
|
||||
{
|
||||
#region members
|
||||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region utilities
|
||||
|
||||
private T GetService<T>() where T : Grpc.Core.ClientBase<T>
|
||||
{
|
||||
return _serviceProvider.GetService<T>() ??
|
||||
throw new Exception($"requested service not registered: {typeof(T).FullName}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ApplicationContractContext(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
#region FM
|
||||
|
||||
//public FileLogContract.FileLogContractClient FileManagements => GetService<FileLogContract.FileLogContractClient>();
|
||||
|
||||
#endregion
|
||||
#region CMS
|
||||
public PackageContract.PackageContractClient Packages => GetService<PackageContract.PackageContractClient>();
|
||||
public FileInfoContract.FileInfoContractClient FileInfos => GetService<FileInfoContract.FileInfoContractClient>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user