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));
 }
Example #3
0
 private static bool UsingAbp(IFileConfigurationRepository fileConfigRepo)
 {
     return(fileConfigRepo.GetType() == typeof(AbpEfCoreFileConfigurationRepository));
 }
Example #4
0
        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;
 }
Example #7
0
 public FileConfigurationController(IFileConfigurationRepository repo, IFileConfigurationSetter setter, IServiceProvider provider)
 {
     _repo     = repo;
     _setter   = setter;
     _provider = provider;
 }
Example #8
0
 private void GivenTheEnvironmentNameIsUnavailable()
 {
     _environmentName = null;
     _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName);
     _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object);
 }
Example #9
0
 private void GivenIHaveAConfiguration()
 {
     _fileConfigRepository = new AbpEfCoreFileConfigurationRepository(_configCacheOptions, _cachOptions.Object, _ocelotRepository, _loggerFactory.Object);
 }
Example #10
0
 public FileConfigurationRepositoryTests()
 {
     _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName);
     _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object);
 }
Example #11
0
 public FileConfigurationProvider(IFileConfigurationRepository repo)
 {
     _repo = repo;
 }