Using Microsoft.Extensions.Options.IOptionsSnapshot you can configure one config class multiple times.
Imagine I have:
{
"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
}
}
I have to deal with the following restrictions:
- I cannot change my
Addressclass to add aNameproperty and transformFavoriteAddressesto an array - Neither I can apply inheritance or have wrapper around this
Addressclass
As you can see, many Address objects and for some it is impossible to know the chosen name. Regardless where it is registered, it all ends up as a named option.
So how can I get a list of all registred names for the Address options?