So I have this rather large application that uses a TagType enum. The use of TagType is widespread in the codebase. I am modding the code to allow users to add tags, in other words to "extend" the enum so to speak at Runtime
The app is a database front end. We cannot change the codebase. We cannot make significant changes so as to render the codebase "untested". Therefore we cannot implement what might be considered "best practice". We simply need a way to "extend" the type - at runtime - so that the codebase continues to function "as was" but with the ability to add a small piece of code that will implement - by whatever means possible - this change
current definition of TagType is
public enum TagType {
__RESERVED__ = 0,
__Raised__ = 1,
__Closed__ = 2
}
but we need some way of "extending" this values at runtime so that the codebase functionality remains runnable , i.e. where the code might for example test:
if (localTag == __Raised__)
db.Search(localTag)
and so on ...
your solution doesn't need to be an enum, the TagType is in its own file and we can change the implementation of TagType to anything PROVIDED the rest of the codebase compiles and runs.
By the way, the code needs to be portable and not make assumptions on O/S - so reflection based solutions might not be possible.
What I have tried:
I scour of google pages reveals many solutions to individual situations but having read these, none of them I have read appear to fit this requirement. So please, if you intend to refer me to google then please can I ask very politely that you go an help some other codeproject member rather than post here.
Also, this looked like a good solution, however it is dependent on assemblies and I didn't want to force the code to a particular os.
tps://stackoverflow.com/questions/857414/dynamically-create-an-enum