I have a program that uses tables of hard-coded values. E.g.
public static readonly IDictionary<SpecBuild, BuildInfo> Builds = new Dictionary<SpecBuild, BuildInfo> {
{ SpecBuild.WarriorArms,
new BuildInfo {
Class = Class.Warrior,
Name = "Arms",
Role = Role.Melee
}
},
{ SpecBuild.WarriorFury,
new BuildInfo {
Class = Class.Warrior,
Name = "Fury",
Role = Role.Melee
}
},
{ SpecBuild.WarriorProtection,
new BuildInfo {
Class = Class.Warrior,
Name = "Protection",
Role = Role.Tank
}
}, ...
This data seldom changes, so I am fine with hard-coding it. The problem is that it is hard to read this data, and formatting doesn't work because Resharper reformats it differently.
Ideally I would want a special format file with a custom VS2010 viewer that would present this info as a table and either generate a C# code for those table as part of compilation process, or maybe even compile it directly into MSIL (CLR).
I am looking for a turnkey solution, the problem is not severe enough to warrant any extra development.
I would (and have, many times) push this type of data into a file (perhaps via a resx). Then load the data via your choice of deserializer. If it needs to be easily edited, maybe JSON via JavaScriptSerializer or JSON.NET. If it is told of data and performance is key, maybe something more hardcore (maybe binary). XML is of course a viable choice too.
Other options might included an embedded database, if the scenario warrants it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With