public void InstallServices(IServiceCollection services, IConfiguration configuration) { var azureSettingValues = new AzureSetting(); configuration.GetSection(nameof(AzureSetting)).Bind(azureSettingValues); if (!services.Any(x => x.ServiceType == typeof(AzureSetting))) { services.AddSingleton(azureSettingValues); } services.AddScoped <IBusinessEngineFactory, BusinessEngineFactory>(); //Engines injection var engineTypes = typeof(BusinessEngineFactory).Assembly .ExportedTypes .Where(x => typeof(IBusinessEngine).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract).ToList(); engineTypes.ForEach(engineType => { services.AddScoped(engineType.GetInterface($"I{engineType.Name}"), engineType); }); }
public TokenManager( IHttpClientFactory httpClientFactory, AzureSetting azureSetting, SpoSetting spoSetting) { httpClient = httpClientFactory.CreateClient(); this.azureSetting = azureSetting; this.spoSetting = spoSetting; }
public void InstallServices(IServiceCollection services, IConfiguration configuration) { var azureSettingValues = new AzureSetting(); configuration.GetSection(nameof(AzureSetting)).Bind(azureSettingValues); if (!services.Any(x => x.ServiceType == typeof(AzureSetting))) { services.AddSingleton(azureSettingValues); } services.AddScoped <IBusinessEngineFactory, BusinessEngineFactory>(); //Engines injection services.AddTransient <IEmployeeEngine, EmployeeEngine>(); }
public Settings SaveSettings(Settings settings) { var result = _ServiceContext.Settings.ToList(); result.ForEach(x => _ServiceContext.DeleteObject(x)); var newSetting = new AzureSetting(_encryptionKey, settings); _ServiceContext.AddObject(AzureSettingContext.SettingsTable, newSetting); _ServiceContext.SaveChanges(); //AzureCache.Remove(AzureCacheKey); //AzureCache.Put(AzureCacheKey, newSetting.ToCacheSetting()); lock (_lock) { _settingCache = newSetting; _lastCacheCheck = DateTime.Now; } return(settings); }
public Settings GetSettings() { if (_settingCache != null && _lastCacheCheck > DateTime.Now.AddMinutes(-5)) { return(_settingCache.ToFrameworkSetting(_encryptionKey)); } lock (_lock) { var azureSetting = _ServiceContext.Settings.FirstOrDefault(); if (azureSetting == null) { return(new Settings()); } //AzureCache.Put(AzureCacheKey, azureSetting.ToCacheSetting()); _settingCache = azureSetting; _lastCacheCheck = DateTime.Now; return(azureSetting.ToFrameworkSetting(_encryptionKey)); } }
public TokenManager(AzureSetting azureSetting) { this.azureSetting = azureSetting; }