Files
FrontOffice.BFF/src/FrontOffice.BFF.Infrastructure/Services/ApplicationContractContext.cs

75 lines
3.6 KiB
C#
Raw Normal View History

using CMSMicroservice.Protobuf.Protos.Category;
2025-09-28 00:45:26 +03:30
using CMSMicroservice.Protobuf.Protos.OtpToken;
using CMSMicroservice.Protobuf.Protos.Package;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
2025-11-17 20:39:31 +03:30
using CMSMicroservice.Protobuf.Protos.Products;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
using CMSMicroservice.Protobuf.Protos.ProductImages;
2025-09-28 00:45:26 +03:30
using CMSMicroservice.Protobuf.Protos.User;
using CMSMicroservice.Protobuf.Protos.UserAddress;
using CMSMicroservice.Protobuf.Protos.UserCarts;
using CMSMicroservice.Protobuf.Protos.UserContract;
2025-09-28 00:45:26 +03:30
using CMSMicroservice.Protobuf.Protos.UserOrder;
2025-11-25 02:46:57 +03:30
using CMSMicroservice.Protobuf.Protos.UserWallet;
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
using FrontOffice.BFF.Application.Common.Interfaces;
using Microsoft.Extensions.DependencyInjection;
2025-10-13 13:00:03 +03:30
using PYMSMicroservice.Protobuf.Protos.Transaction;
namespace FrontOffice.BFF.Infrastructure.Services;
public class ApplicationContractContext : IApplicationContractContext
{
#region members
2025-09-28 00:45:26 +03:30
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
2025-09-28 00:45:26 +03:30
#region CMS
public PackageContract.PackageContractClient Package => GetService<PackageContract.PackageContractClient>();
2025-11-17 20:39:31 +03:30
public ProductsContract.ProductsContractClient Product => GetService<ProductsContract.ProductsContractClient>();
public ProductGallerysContract.ProductGallerysContractClient ProductGallerys => GetService<ProductGallerysContract.ProductGallerysContractClient>();
public ProductImagesContract.ProductImagesContractClient ProductImages => GetService<ProductImagesContract.ProductImagesContractClient>();
public CategoryContract.CategoryContractClient Category => GetService<CategoryContract.CategoryContractClient>();
public PruductCategoryContract.PruductCategoryContractClient ProductCategory => GetService<PruductCategoryContract.PruductCategoryContractClient>();
public UserCartsContract.UserCartsContractClient UserCart => GetService<UserCartsContract.UserCartsContractClient>();
2025-09-28 00:45:26 +03:30
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
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>();
2025-11-25 02:46:57 +03:30
public UserWalletContract.UserWalletContractClient UserWallet => GetService<UserWalletContract.UserWalletContractClient>();
public UserWalletChangeLogContract.UserWalletChangeLogContractClient UserWalletChangeLog => GetService<UserWalletChangeLogContract.UserWalletChangeLogContractClient>();
2025-09-28 00:45:26 +03:30
#endregion
2025-10-13 13:00:03 +03:30
#region PYMS
public TransactionContract.TransactionContractClient ZarinTransactions => GetService<TransactionContract.TransactionContractClient>();
#endregion
}