コード例 #1
0
        public RepositoryConfiguration(IConfigurationReader config)
        {
            try
            {
                databaseId  = config.GetValue <string>(DataBaseIdKey);
                databaseUri = UriFactory.CreateDatabaseUri(databaseId);
                endPointUrl = config.GetValue <string>(EndPointUrlKey);
                authKey     = config.GetValue <string>(AuthConfigKey).ToSecureString();

                docDbClient         = new DocumentClient(new Uri(endPointUrl), authKey);
                userCollectionId    = config.GetValue <string>(UserCollectionIdKey);
                productCollectionId = config.GetValue <string>(ProductCollectionIdKey);
                collectionIds       = new List <string>
                {
                    userCollectionId, productCollectionId
                };

                CreateDatabaseIfNotExistsAsync().Wait();
            }
            catch (Exception)
            {
                // TODO : Handle exception.
                throw;
            }
        }
コード例 #2
0
        public IActionResult Index()
        {
            HomePageModel model = new HomePageModel
            {
                SupportedOs = _configReader.GetValue <string>("SupportedOs"),
                ApiVersion  = _configReader.GetValue <double>("ApiVersion"),
                IsDebug     = _configReader.GetValue <bool>("IsDebug"),
                Miliseconds = _configReader.GetValue <int>("Miliseconds")
            };

            return(View(model));
        }
コード例 #3
0
        public IActionResult Index()
        {
            var configItem  = _configReader.GetValue <string>("SiteName");
            var configModel = new ProjectConfigModel
            {
                Name  = "SiteName",
                Value = configItem
            };
            // bu değer aktif olmadığından gelmemeli
            var configItem2 = _configReader.GetValue <int?>("MaxItemCount");

            return(View(configModel));
        }
コード例 #4
0
        public IActionResult Index()
        {
            var result = _configurationReader.GetValue <string>("SiteName");

            ViewBag.Result = result;
            return(View());
        }
コード例 #5
0
        public void TestMethod_GetValue_ServiceB()
        {
            _reader = new ConfigurationReader("SERVICE-B", ConfigurationManager.ConnectionStrings["TrendyolEntities"].ConnectionString, 1000);
            bool isBasketEnabled = _reader.GetValue <bool>("IsBasketEnabled");

            Assert.AreEqual(true, isBasketEnabled);
        }
コード例 #6
0
        public void TestMethod_GetValue_ServiceA()
        {
            _reader = new ConfigurationReader("SERVICE-A", ConfigurationManager.ConnectionStrings["TrendyolEntities"].ConnectionString, 1000);
            string siteName = _reader.GetValue <string>("SiteName");

            Assert.AreEqual("trendyol.com", siteName);
        }
コード例 #7
0
        public void OnGet(string searchString)
        {
            CurrentFilter = searchString;

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                CacheSearchResult = _configurationReader.GetValue <string>(searchString);
                ConfigurationList = _configurationReader.SearchByName(searchString).Select(a => new Configuration
                {
                    Type     = a.Type,
                    Value    = a.Value,
                    IsActive = a.IsActive,
                    Name     = a.Name,
                    Id       = a.Id
                }).ToList();
            }
            else
            {
                ConfigurationList = _configurationReader.GetAll().Select(a => new Configuration
                {
                    Type     = a.Type,
                    Value    = a.Value,
                    IsActive = a.IsActive,
                    Name     = a.Name,
                    Id       = a.Id
                }).ToList();
            }
        }
コード例 #8
0
        public ActionResult Get(string key, string type)
        {
            dynamic value = null;

            if (type == "string")
            {
                value = _configurationReader.GetValue <string>(key);
            }
            else if (type == "bool")
            {
                value = _configurationReader.GetValue <bool>(key);
            }
            else if (type == "int")
            {
                value = _configurationReader.GetValue <int>(key);
            }

            return(Ok(value));
        }
コード例 #9
0
        static void Main(string[] args)
        {
            ConfigSettings.ApplicationName          = "ServiceA";
            ConfigSettings.ConnectionString         = "mongodb://localhost:27017";
            ConfigSettings.RefreshTimerIntervalInMs = 5000;

            _container = DependencyService.Instance.CurrentResolver;

            IConfigurationReader _configurationReader = _container.Resolve <IConfigurationReader>();

            string siteName = _configurationReader.GetValue <string>("SiteName");

            Console.WriteLine("Sitename: " + siteName);

            bool isBasketEnabled = _configurationReader.GetValue <bool>("IsBasketEnabled");

            Console.WriteLine("IsBasketEnabled" + isBasketEnabled);


            Console.ReadKey();
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Arguments prms = new Arguments();

            prms.Add("applicationName", "SERVICE - A");
            prms.Add("refreshTimerIntervalInMs", 10000);
            prms.Add("connectionString", "Deneme");

            IConfigurationReader configurationReader = IocHelper.Resolve <IConfigurationReader>(prms);


            var val = configurationReader.GetValue <int>("MaxItemCount");

            Console.ReadKey();
        }
コード例 #11
0
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
     while (!stoppingToken.IsCancellationRequested)
     {
         try {
             _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
             var value = _configurationReader.GetValue <string>("SiteName");
             _logger.LogInformation($"Loaded value {value} for the settings key 'SiteName'");
             await Task.Delay(TimeSpan.FromSeconds(20), stoppingToken);
         }
         catch (Exception e) {
             _logger.LogError(e, "Well, we'll keep working...");
         }
     }
 }
コード例 #12
0
        public void When_Call_Not_ActiveValue_Then_It_Should_Return_Null(string name)
        {
            var configItem2 = _configReader.GetValue <int?>("MaxItemCount");

            Assert.IsTrue(configItem2 == null);
        }
コード例 #13
0
 public void Get_value()
 {
     var val = _configurationReader.GetValue <int>("MaxItemCount");
 }
コード例 #14
0
 public T GetValue <T>(string key) => _advancedConfigurationReader.GetValue <T>(key);
コード例 #15
0
 public void No_Configuration_Throws()
 {
     Should.Throw <InvalidOperationException>(() => _configurationReader.GetValue <bool>("key"));
 }