コード例 #1
0
        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));
        }
コード例 #2
0
 private static bool UsingConsul(IFileConfigurationRepository fileConfigRepo)
 {
     return(fileConfigRepo.GetType() == typeof(ConsulFileConfigurationRepository));
 }
コード例 #3
0
 private static bool UsingAbp(IFileConfigurationRepository fileConfigRepo)
 {
     return(fileConfigRepo.GetType() == typeof(AbpEfCoreFileConfigurationRepository));
 }
コード例 #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());
        }
コード例 #5
0
 public ContentFileFacts()
 {
     _config = Substitute.For <IFileConfigurationRepository>();
     _reload = Substitute.For <IReloadService>();
 }
コード例 #6
0
 public EditorController(IFileConfigurationRepository fileConfigurationRepository, IReloadService reload)
 {
     _fileConfigRepo = fileConfigurationRepository;
     _reload         = reload;
 }
コード例 #7
0
 public FileConfigurationController(IFileConfigurationRepository repo, IFileConfigurationSetter setter, IServiceProvider provider)
 {
     _repo     = repo;
     _setter   = setter;
     _provider = provider;
 }
コード例 #8
0
 private void GivenTheEnvironmentNameIsUnavailable()
 {
     _environmentName = null;
     _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName);
     _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object);
 }
コード例 #9
0
 private void GivenIHaveAConfiguration()
 {
     _fileConfigRepository = new AbpEfCoreFileConfigurationRepository(_configCacheOptions, _cachOptions.Object, _ocelotRepository, _loggerFactory.Object);
 }
コード例 #10
0
 public FileConfigurationRepositoryTests()
 {
     _hostingEnvironment.Setup(he => he.EnvironmentName).Returns(_environmentName);
     _repo = new DiskFileConfigurationRepository(_hostingEnvironment.Object);
 }
コード例 #11
0
 public FileConfigurationProvider(IFileConfigurationRepository repo)
 {
     _repo = repo;
 }