So, if I have a method to parse a text file and return a list of list key values , and you want to create objects from the returned kvps (each kvps list represents a different object), what would be the best method?
The first method that comes to mind is quite simple, just save the list of keywords:
private const string NAME = "name";
private const string PREFIX = "prefix";
and check the keys that I get for the constants I want defined above. This is pretty much the main part of the project I'm working on, so I want to do it well; Does anyone have more reliable suggestions (not to mention the fact that something is inherently irrelevant to the method described above - I'm just asking)?
Edit:
More information was requested. I work on a little game in my free time, and I create a game world with configuration files. There are four - one defines all creatures, the other defines all areas (and their locations on the map), the other defines all objects, and the latter defines various configuration parameters and things that do not fit together. With the first three configuration files, I will create objects based on the contents of the files - it will be quite heavy for the text, so there will be many lines, such as names, plurals, prefixes - that’s what. The configuration values look like this:
-
key: value
key: value
-
key: value
key: value
-
If the string '-' denotes a new section / object.
source
share