What is a good collection/container to use for basically storing the contents of a switch-statement with multiple fallthrough situations? I guess, a more accurate way is, what's a good C# solution for a "many-keys-one-value" lookup? I checked through the System.Collections namespace and its associated namespaces, but didn't find anything that particularly lended itself to many-keys-one-value.
Recently, I wrote myself a small console program to construct and validate the XML files I need for my web application, to avoid the errors that occur when manually writing it. But for the initial version, I hardcoded a number of elements which are slightly mutable - specifically a few dictionaries for validation and one large switch-statement that has a hefty set of fallthrough options. While this will work for quite a few months to come, it may be necessary to eventually update these hardcoded elements, which currently would require editing the source file. In the interest of avoiding this, I decided that I'd store the dictionary and switch-statement information in an XML file (which eventually evolved, in a horribly recursive trend, to writing a program to construct and validate those XML files for me). Now, in storing this in a file, when I retrieve the data I can't simply rebuild the switch statement like I can the dictionaries. So I simply need to simulate the effect of a switch statement, which basically means I need several "keys" to reference the same "value".
Example snippet from the switch statement. This method will convert special value inputs into a corresponding ID, mostly to save on human memory space trying to memorize the values. Basically as illustrated, I'd like a container to store the several keys that all output a single value.
private static string DiscernRegistrationId(string str)
{
string retVal = str;
switch (str.ToLowerKey()) //shortcut extension for str.Replace(" ","").Replace(".","").ToLowerInvariant()
{
case "computerpackage":
case "comppackage":
case "cpackage":
case "computerpkg":
case "comppkg":
case "cpkg":
retVal = "0x0100C73692D109C741A1B8846141B47519C8";
break;
case "mobilepackage":
case "mobpackage":
case "mpackage":
case "mobilepkg":
case "mobpkg":
case "mpkg":
retVal = "0x010081F753F0A4A5412CB6A8E9F8CD193F58";
break;
//More cases follow
}
return retVal;
}