mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-02 23:26:36 +08:00
配置文件开关,数据库读写分离
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Yi.Framework.WebCore
|
||||
/// <summary>
|
||||
/// appsettings.json操作类
|
||||
/// </summary>
|
||||
public class Appsettings
|
||||
public class Appsettings
|
||||
{
|
||||
static IConfiguration Configuration { get; set; }
|
||||
static string contentPath { get; set; }
|
||||
@@ -26,7 +26,7 @@ namespace Yi.Framework.WebCore
|
||||
.Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true })//这样的话,可以直接读目录里的json文件,而不是 bin 文件夹下的,所以不用修改复制属性
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
||||
public Appsettings(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
@@ -52,6 +52,23 @@ namespace Yi.Framework.WebCore
|
||||
return "";
|
||||
}
|
||||
|
||||
public static bool appBool(params string[] sections)
|
||||
{
|
||||
|
||||
return Bool(app(sections));
|
||||
|
||||
}
|
||||
|
||||
public static bool Bool(object thisValue)
|
||||
{
|
||||
bool reval = false;
|
||||
if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval))
|
||||
{
|
||||
return reval;
|
||||
}
|
||||
return reval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取配置信息数组
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user