I'm very proud of myself for this:
I didn't explain it fully, but the methods do need to do different things to get the base type or list type setting. I could have shunted this down to the Configuration class, but I had already started creating a second List method anyway.
Separating the <list<T>> from the <T> method is prolly a good thing anyway so each method doesn't get too complex
public T GetCompanySetting<t>(string key)
{
if (typeof (T).IsGenericType && typeof (T).GetInterfaces().Contains(typeof (System.Collections.IEnumerable)))
{
var t = typeof (T).GetGenericArguments()[0];
MethodInfo method = typeof (Configuration).GetMethod("QueryList").MakeGenericMethod(new[] {t});
return (T)method.Invoke(null,new object []{ CompanyId, null, "AccountManagement", key, null});
}
return Configuration.Query<t>(CompanyId, null, "AccountManagement", key);
}
</t></t>
I wanted this method to be "on rails" for the caller. My colleague who will use this method writes in VB and isn't too familiar with generics.
Thanks for taking a look, guys ^_^