I'm trying to whip up a POC of a system which allows you to create and modify enumerations that are eventually used in an application using the front-end. Something like dynamic enums.
For example, in a hypothetical bug tracker application, we can have a status
enum that could have values of open
,accepted
and closed
. All these enums (and their corresponding values) can be changed in real-time via the UI, so it is possible for an admin to come up with a new reassigned
value for example (through an Admin page, most probably) somewhere down the application's lifetime. It would also be possible to create new enums as well, which in turn have their own values (for example, a complexity
enum).
The way I'm currently envisioning it is that I'll have an Enumeration
class, which has a 1:*
referential with an EnumerationValue
class.
public class Enumeration {
public string Name { get; set; }
public ICollection<EnumerationValue> Values { get; set; }
}
public class EnumerationValue {
public string Name { get; set; }
public string Description { get; set; }
}
That's the easy part. When I get to creating the entity that actually uses these dynamic enums, I hit a snag.
Let's say I'm creating the BugRecord
entity, which consequently has a Status
property. Following the logic above, I'd have to write it along the lines of:
public class BugRecord {
public EnumerationValue Status { get; set; }
}
But given that I could have lots of different Enumeration
s (and EnumerationValue
s), is there a way for me to restrict BugRecord.Status
values to only EnumerationValue
s in the status Enumeration
? If not how would you recommend I tackle a problem of this kind?
Enumeration
entities are more of just a grouping? The actual values will be theEnumerationValue
entities themselves. So if a bug record's status isactive
, thenBugRecord.Status
is analogous tonew EnumerationValue { Name = "Active" }
. Or something like that. What do you have in mind? – Richard Neil Ilagan Oct 28 '11 at 4:02