如何将configurationSection作为字符串?

时间:2018-04-18 14:04:51

标签: configuration .net-core

我正在使用.NETCore 2.0我希望将完整的配置部分加载为字符串。

具体来说,我想做Json-Schema验证,我的架构存储在appsettings.json中:

{
  ...
  "schemas": {
    "project": {
      "title": "Project",
      "type": "object",
      "required": [ "param1" ],
      "additionalProperties": false,
      "properties": {
        "param1": {
          "type": "string"
        },
        "param2": {
          ...
        }
      }
    }
  },
  ...
}

现在我想将配置节“schemas.project”作为字符串加载,让Json.NET Schema进行模式解析。

这样的事情:

var schemaString = this.configuration.GetSection("schemas.project").Get<string>();
var schema = JSchema.Parse(schemaString);
...

有没有办法将完整的配置部分加载为字符串?否则我会在schema-file中读取字符串..

0 个答案:

没有答案
相关问题