I am writing a text file parser for a specific matching condition, and in a couple of the files I need to do some custom manipulation. What I would like to do is store the name of the custom procedure that is being used in an external XML file with the other rules. Most won't use this, and I found this answer regarding the action call:
The above has the following dictionary definition
private static readonly IDictionary<string,Action<string>> actionByType =
new Dictionary<string,Action<string>>
Element adding from XML file in my current program (These two elements will be added)
foreach (XmlNode node in nodes)
{
Client holding = new Client();
holding.has_custom =
Convert.ToBoolean(
node.SelectSingleNode("has_custom").InnerText);
holding.custom_call =
node.SelectSingleNode("custom_call").InnerText;
clients.Add(holding);
}
As I go through this, how do I assign the name of the custom call as an action to be called in the dictionary? And then do I use a case statement with the generic parse as the default?
actionByTypeis a dictionary. What are you proposing as an alternative?