SOME CONTEXT
- one of my projects requires carrying around some of "metadata" (yes I hate using that word).
- What the metadata specifically consists of is not important, only that it's more complex than a simple "table" or "list" - you could think of it as a mini-database of information
- Currently I have this metadata stored in an XML file and have an XSD that defines the schema.
- I want to package this metadata with my project, currently that means keeping the XML file as a resource
- However, I have been looking for a more strongly-typed alternative. I am considering moving it from an XML file to C# code - so instead of using XML apis to traverse my metadata, relying on .NET code via reflection on types
- Besides the strong(er) typing, some useful characteristics I see from using an assembly are for this: (1) I can refactor the "schema" to some extent with tools like Resharper, (2) The metadata can come with code, (3) don't have to rely on any external DB component.
THE QUESTIONS
- If you have tried something like this, I am curious about what you learned.
- Was your experience positive?
- What did you learn?
- What problems in this approach did you uncover?
- What are some considerations I should take into account?
- Would you do this again?
NOTES
- Am not asking for how to use Reflection - no help is needed there
- Am fundamentally asking about your experiences and design considerations
UPDATE: INFORMATION ABOUT THE METADATA
Because people are asking I'll try describing the metadata a bit more. I'm trying to abstract a bit - so this will seem a bit artificial.
There are three entities in the model:
- A set of "groups" - each group has a unique name and several properites (usually int values that represent ID numbers of some kind)
- Each "group" contains 1 or more "widgets" (never more than 50) - each item has properties like name (therea are multiple names), IDs, and various boolean properties.
- Each widget contains a one or more "scenarios". Each "scenario" is documentation- a URL to a description of how to use the widget.
Typically I need to run these kinds of "queries"
- Get the names of all the widgets
- Get the names of all groups that contain at least one widget where BoolProp1=true
- Get given the ID of a widget, which group contains that widget
How I was thinking about modelling the entities in the assembly
- There are 3 classes: Group, Widget, Documentation
- There are 25 Groups so I will have 25 Group classes - so "FooGroup" will derive from Group, same pattern follows for widgets and documentation
- Each class will have attributes to account for names, ids, etc.