Closed LordMike closed 3 years ago
There is a IRegionConverter interface to convert between enums and strings. I've improved it a bit so now it supports conversion both ways.
Use it like this:
RegionConverter converter = new RegionConverter(AmazonS3RegionData.Instance);
var regionInfo = converter.GetRegion(TestRegion.RegionOne);
RegionInfo contains the region code, name of the region, and the enum value.
You should be able to create a TypeConverter that converts between the enum and string with that.
The S3 and other configs seem to prefer the region codes as enums - but my users will provide it as strings. Ideally, it should be possible to use AmazonS3Region directly in the config files, and have Options convert it to the enum from the string it was. This can be done by implementing a TypeConveter and attributing the enums with the
[TypeConverter]
attribute.At runtime, Options will call
Convert.ChangeType()
which then calls the custom TypeConverter.Could this be added? :)