예제 #1
0
        public static IServiceCollection AddConfigurationsRequestService(this IServiceCollection services, string apiServer)
        {
            ConfigurationsInjectionHelper.TryInit(ref services);
            ServerHostHelper.AddServerHostByName(ServerHostNameConts.ConfigurationApi, apiServer);
            #region Base
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            #endregion Base

            #region Location Services
            services.TryAddScoped <ILocationRequestService, LocationRequestService>();
            services.TryAddScoped <ICityRequestService, CityRequestService>();
            services.TryAddScoped <ICountryRequestService, CountryRequestService>();
            services.TryAddScoped <IZoneDistrictRequestService, ZoneDistrictRequestService>();
            #endregion Location Services

            services.TryAddScoped <ICurrencyRequestService, CurrencyRequestService>();
            services.TryAddScoped <ICommonValueRequestService, CommonValueRequestService>();
            services.TryAddScoped <ICommonResourceRequestService, CommonResourceRequestService>();
            services.TryAddScoped <IPortalLanguageRequestService, PortalLanguageRequestService>();
            services.TryAddScoped <IPortalLocationRequestService, PortalLocationRequestService>();
            services.TryAddScoped <ICommonLanguagesRequestServices, CommonLanguagesRequestServices>();
            services.TryAddScoped <IMultiLanguageService, MultiLanguageService>();

            return(services);
        }
 private static IServiceCollection TryAddRequiredService(this IServiceCollection services, string binFolderPath)
 {
     services.TryAppSettingConfigurationService(binFolderPath);
     services.TryAddAppSettingEnvironmentService();
     ConfigurationsInjectionHelper.TryInit(ref services);
     return(services);
 }
        public static T Value <T>(this EnvironmentOptionBase <T> option)
        {
            var appSettingEnvironmentService = ConfigurationsInjectionHelper.GetRequiredService <IAppSettingEnvironmentService>();
            var environment = appSettingEnvironmentService.Enviroment;

            switch (environment)
            {
            case 0:
                return(option.LOCAL);

            case 1:
                return(option.VN);

            case 2:
                return(option.BETA);

            case 3:
                return(option.LIVE);

            default: throw new Exception("Please check environment variable in appsetting.json");
            }
        }