private static async Task <Response> SetConfig(IApplicationBuilder builder, IOptions <FileConfiguration> fileConfiguration, IFileConfigurationSetter setter, IOcelotConfigurationProvider provider, IFileConfigurationRepository repo) { if (UsingConsul(repo)) { return(await SetUpConfigFromConsul(builder, repo, setter, fileConfiguration)); } return(await setter.Set(fileConfiguration.Value)); }
private static bool UsingConsul(IFileConfigurationRepository fileConfigRepo) { return(fileConfigRepo.GetType() == typeof(ConsulFileConfigurationRepository)); }
private static bool UsingAbp(IFileConfigurationRepository fileConfigRepo) { return(fileConfigRepo.GetType() == typeof(AbpEfCoreFileConfigurationRepository)); }
private static async Task <Response> SetUpConfigFromConsul(IApplicationBuilder builder, IFileConfigurationRepository consulFileConfigRepo, IFileConfigurationSetter setter, IOptions <FileConfiguration> fileConfig) { Response config = null; var ocelotConfigurationRepository = (IOcelotConfigurationRepository)builder.ApplicationServices.GetService( typeof(IOcelotConfigurationRepository)); var ocelotConfigurationCreator = (IOcelotConfigurationCreator)builder.ApplicationServices.GetService( typeof(IOcelotConfigurationCreator)); var fileConfigFromConsul = await consulFileConfigRepo.Get(); if (fileConfigFromConsul.Data == null) { config = await setter.Set(fileConfig.Value); var hack = builder.ApplicationServices.GetService(typeof(ConsulFileConfigurationPoller)); } else { var ocelotConfig = await ocelotConfigurationCreator.Create(fileConfigFromConsul.Data); if (ocelotConfig.IsError) { return(new ErrorResponse(ocelotConfig.Errors)); } config = await ocelotConfigurationRepository.AddOrReplace(ocelotConfig.Data); if (config.IsError) { return(new ErrorResponse(config.Errors)); } //todo - this starts the poller if it has been registered...please this is so bad. var hack = builder.ApplicationServices.GetService(typeof(ConsulFileConfigurationPoller)); } return(new OkResponse()); }
public ContentFileFacts() { _config = Substitute.For <IFileConfigurationRepository>(); _reload = Substitute.For <IReloadService>(); }
public EditorController(IFileConfigurationRepository fileConfigurationRepository, IReloadService reload) { _fileConfigRepo = fileConfigurationRepository; _reload = reload; }
public FileConfigurationController(IFileConfigurationRepository repo, IFileConfigurationSetter setter, IServiceProvider provider) { _repo = repo; _setter = setter; _provider = provider; }
private void GivenTheEnvironmentNameIsUnavailable() { _environmentName = null; _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName); _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object); }
private void GivenIHaveAConfiguration() { _fileConfigRepository = new AbpEfCoreFileConfigurationRepository(_configCacheOptions, _cachOptions.Object, _ocelotRepository, _loggerFactory.Object); }
public FileConfigurationRepositoryTests() { _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName); _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object); }
public FileConfigurationProvider(IFileConfigurationRepository repo) { _repo = repo; }