配置文件开关,数据库读写分离

This commit is contained in:
橙子
2021-10-26 15:09:07 +08:00
parent b29b6be734
commit 5d5452b531
30 changed files with 397 additions and 163 deletions

View File

@@ -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>