小编bor*_*o2g的帖子

引用依赖于ConfigurationManager的.net core 2中的.net框架程序集

我们有一些常用的4.5.2类库 ConfigurationManager.AppSettings[key]

是否可以在.net core 2应用程序中引用这些内容,以便在引擎盖下正确修补配置?即旧的调用ConfigurationManager.AppSettings[key]正确读取配置,从json或xml,但在.netcore2应用程序内.

如果我将keys问题移植到appSettings.json,则调用ConfigurationManager.AppSettings始终返回null.

一个例子是:

{
"Logging": {
    "IncludeScopes": false,
    "Debug": {
        "LogLevel": {
            "Default": "Warning"
        }
    },
    "Console": {
        "LogLevel": {
            "Default": "Warning"
        }
    }
},
"appSettings": {"test": "bo"},
"test": "hi"
}
Run Code Online (Sandbox Code Playgroud)

然后:

[HttpGet]
public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2", ConfigurationManager.AppSettings["test"] , ConfigurationManager.AppSettings["appSettings:test"] };
}
Run Code Online (Sandbox Code Playgroud)

将显示:

["value1","value2",null,null]
Run Code Online (Sandbox Code Playgroud)

asp.net configuration .net-core-2.0

8
推荐指数
1
解决办法
658
查看次数

在 C# 驱动程序中订阅 Redis 过期事件?

如果您向要添加到 Redis 的实体添加过期时间,例如在 ServiceStack.Redis 中:

redisClient.Set(elementKey, "some cached value", DateTime.Now.AddMinutes(2));
Run Code Online (Sandbox Code Playgroud)

那么您如何订阅该元素的到期时间。期望的结果是:

redisClient.Subscribe(elementKey, "expire", DoSomethingBasedOnKey)
Run Code Online (Sandbox Code Playgroud)

c# redis

4
推荐指数
1
解决办法
4712
查看次数

在Azure Devops中,从Bitbucket提取时如何选择Yaml管道

从Azure Devops存储库提取代码时,您可以选择基于yaml文件配置生成管道:

yaml管道
但是,当使用bitbucket作为存储库时,此选项不可用。是否可以将YAML“配置作为代码”与BitBucket存储库一起使用?

git bitbucket azure azure-devops

1
推荐指数
1
解决办法
185
查看次数