Earlier I asked about mapping restricted/enumerated attributes to a different set of values in the destination schema, e.g.:
- Y->Approved
- N->Denied
- U->Unknown
trayburn suggested a functoid, so here's my first take on it (minus the boilerplate functoid stuff):
public string HashMatch(string inputValue, string valuePair1, string valuePair2, string valuePair3)
{
string[] hashPair = { valuePair1, valuePair2, valuePair3 };
System.Collections.Hashtable ht = new System.Collections.Hashtable(hashPair.Length);
foreach (string entry in hashPair)
{
string[] keyValuePair = entry.Split(new char[] { '>' });
ht.Add(keyValuePair[0], keyValuePair[1]);
}
return (string)ht[inputValue];
}
Usage would look like a link from the source schema, followed by constants describing the mapping, e.g. "Y>Approved", "N>Denied", "U>Unknown".
It appears to work for my test cases. So apart from the hackney calling convention and waste of hashtable for a single lookup, is there anything wrong with this approach?
Thanks again