2025-09-28 00:45:26 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.OtpToken;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.Package;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.User;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
2025-11-16 17:29:30 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserContract;
|
2025-09-28 00:45:26 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
2025-09-27 10:36:00 +03:30
|
|
|
using FrontOffice.BFF.Application.Common.Interfaces;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2025-10-13 13:00:03 +03:30
|
|
|
using PYMSMicroservice.Protobuf.Protos.Transaction;
|
2025-09-27 10:36:00 +03:30
|
|
|
|
|
|
|
|
namespace FrontOffice.BFF.Infrastructure.Services;
|
|
|
|
|
|
|
|
|
|
public class ApplicationContractContext : IApplicationContractContext
|
|
|
|
|
{
|
|
|
|
|
#region members
|
|
|
|
|
|
2025-09-28 00:45:26 +03:30
|
|
|
private readonly IServiceProvider _serviceProvider;
|
2025-09-27 10:36:00 +03:30
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2025-09-28 00:45:26 +03:30
|
|
|
#region CMS
|
|
|
|
|
public PackageContract.PackageContractClient Package => GetService<PackageContract.PackageContractClient>();
|
|
|
|
|
|
|
|
|
|
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
|
2025-11-16 17:29:30 +03:30
|
|
|
public UserContractContract.UserContractContractClient UserContract => GetService<UserContractContract.UserContractContractClient>();
|
2025-09-28 00:45:26 +03:30
|
|
|
public UserAddressContract.UserAddressContractClient UserAddress => GetService<UserAddressContract.UserAddressContractClient>();
|
|
|
|
|
|
|
|
|
|
public UserOrderContract.UserOrderContractClient UserOrder => GetService<UserOrderContract.UserOrderContractClient>();
|
|
|
|
|
|
|
|
|
|
public OtpTokenContract.OtpTokenContractClient OtpToken => GetService<OtpTokenContract.OtpTokenContractClient>();
|
|
|
|
|
#endregion
|
2025-10-13 13:00:03 +03:30
|
|
|
|
|
|
|
|
#region PYMS
|
|
|
|
|
public TransactionContract.TransactionContractClient ZarinTransactions => GetService<TransactionContract.TransactionContractClient>();
|
|
|
|
|
|
|
|
|
|
#endregion
|
2025-09-27 10:36:00 +03:30
|
|
|
}
|