Alex Henderson tactfully commented on my last post that he had already been there, done that, and got the tee shirt. Based on his work, a refactored Hash.Init would go like this:
public static IDictionary Init(params Func<object, object>[] funcs)
{
IDictionary values = new Hashtable(funcs.Length, StringComparer.OrdinalIgnoreCase);
foreach (Func<object, object> func in funcs)
{
string key = func.Method.GetParameters()[0].Name;
object value = func(null);
values.Add(key, value);
}
return values;
}
That'll teach me for thinking I'm being innovative :)