Пример #1
0
        public ConfigContainer GetConfig(string basePath, string configFileName)
        {
            var builder = new ConfigurationBuilder();

            builder.SetBasePath(basePath);
            builder.AddJsonFile(configFileName, optional: true);
            builder.AddEnvironmentVariables("APPSETTING_");
            var config    = builder.Build();
            var container = new ConfigContainer();

            container.DatabaseConnectionString = config["PopForums:Database:ConnectionString"];
            var cacheSeconds = config["PopForums:Cache:Seconds"];

            container.CacheSeconds          = cacheSeconds == null ? 90 : Convert.ToInt32(cacheSeconds);
            container.CacheConnectionString = config["PopForums:Cache:ConnectionString"];
            container.CacheForceLocalOnly   = Convert.ToBoolean(config["PopForums:Cache:ForceLocalOnly"]);
            container.SearchUrl             = config["PopForums:Search:Url"];
            container.SearchKey             = config["PopForums:Search:Key"];
            var searchProvider = config["PopForums:Search:Provider"];

            container.SearchProvider        = searchProvider ?? string.Empty;
            container.QueueConnectionString = config["PopForums:Queue:ConnectionString"];
            var logTopicViews = config["PopForums:LogTopicViews"];

            container.LogTopicViews = logTopicViews != null && bool.Parse(logTopicViews);
            return(container);
        }
Пример #2
0
        public ConfigContainer GetConfig(string basePath)
        {
            if (String.IsNullOrWhiteSpace(basePath))
            {
                throw new ArgumentException("Can't setup PopForums configuration without specifying the base path of the app, where PopForums.json should be found.", nameof(basePath));
            }
            var builder = new ConfigurationBuilder();

            builder.SetBasePath(basePath);
            builder.AddJsonFile("PopForums.json");
            var config    = builder.Build();
            var container = new ConfigContainer();

            container.DatabaseConnectionString = config["PopForums:Database:ConnectionString"];
            var cacheSeconds = config["PopForums:Cache:Seconds"];

            container.CacheSeconds = cacheSeconds == null ? 90 : Convert.ToInt32(cacheSeconds);
            return(container);
        }
Пример #3
0
        public ConfigContainer GetConfig(string basePath)
        {
            if (String.IsNullOrWhiteSpace(basePath))
            {
                throw new ArgumentException("Can't setup PopForums configuration without specifying the base path of the app, where PopForums.json should be found.", nameof(basePath));
            }
            var builder = new ConfigurationBuilder();

            builder.SetBasePath(basePath);
            builder.AddJsonFile("PopForums.json");
            builder.AddEnvironmentVariables("APPSETTING_");
            var config    = builder.Build();
            var container = new ConfigContainer();

            container.DatabaseConnectionString = config["PopForums:Database:ConnectionString"];
            var cacheSeconds = config["PopForums:Cache:Seconds"];

            container.CacheSeconds          = cacheSeconds == null ? 90 : Convert.ToInt32(cacheSeconds);
            container.CacheConnectionString = config["PopForums:Cache:ConnectionString"];
            container.CacheForceLocalOnly   = Convert.ToBoolean(config["PopForums:Cache:ForceLocalOnly"]);
            container.SearchUrl             = config["PopForums:Search:Url"];
            container.SearchKey             = config["PopForums:Search:Key"];
            return(container);
        }