Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IOptionsSnapshot获取所有注册名称_C#_.net - Fatal编程技术网

C# IOptionsSnapshot获取所有注册名称

C# IOptionsSnapshot获取所有注册名称,c#,.net,C#,.net,使用Microsoft.Extensions.Options.IOptionsSnapshot可以多次配置一个配置类 想象一下我有: { "MyObject": { "AnotherObject": { "Address": { "City": "..." } // Will be named as "MyObject:AnotherObj

使用
Microsoft.Extensions.Options.IOptionsSnapshot
可以多次配置一个配置类

想象一下我有:

{
    "MyObject": {
        "AnotherObject": {
            "Address": { "City": "..." } // Will be named as "MyObject:AnotherObject:Address" in the snapshot
        }
    },
    "AnotherSetting": {
        "Address": { "City": "..." } 
            // This object will be registered with a Guid.ToString() 
            // (I cannot change the package registering it)
    }
    "FavoriteAddresses" {
        "Home": { "City": "..." },
        "Work": { "City": "..." },
        "Parents": { "City": "..." },
        // ...... Unlimited list
    }
}
我必须处理以下限制:

  • 我无法更改我的
    地址
    类以添加
    名称
    属性并将
    收藏夹地址
    转换为数组
  • 我既不能应用继承,也不能在这个
    地址
    类周围使用包装器
正如您所看到的,许多地址对象,对于某些对象,不可能知道所选的名称。 无论在何处注册,它最终都会成为一个名为的选项

那么如何获取
地址
选项的所有注册名称列表?