I'm developing an ASP.NET MVC 3 application and it uses a complex model which is serialized/deserialized to/from XM开发者_如何学编程L.
Some fields require ISO3166 country codes. I have several defined Enums for other restricted lists (which are very unlikely to change) which are marked with the XmlEnum attribute and displayed neatly using DisplyFor/EditorFor templates.
In order to be consistent I created an Enum of the ISO3166 country codes.
However I am aware these will change overtime requiring me to re-build/deploy the project.
Given the frequency/likelyhood of the ISO3166 codes changing, is this acceptable practice?
Enumerations are conceptually a related collection of constants, ie. they do not change—a client assembly can make this assumption and directly compile in the value of the enum field.
But ISO 3166 does change, often several times a year. For example the creation of the new country South Sudan will need to be reflected in an update.
Isn't this just configuration data? I would XML serialize a List<MyCountryCodeClass>
of the country codes and place this in a CountryCodes.xml
file in the App_Data
folder.
精彩评论