Skip to content

Instantly share code, notes, and snippets.

@hotgazpacho
Created September 13, 2011 14:24
Show Gist options
  • Select an option

  • Save hotgazpacho/1213918 to your computer and use it in GitHub Desktop.

Select an option

Save hotgazpacho/1213918 to your computer and use it in GitHub Desktop.
Looking up a Type, and converting it to a generic parameter for a method
public bool IsSurveillanceNoUnique(string surveillanceNo, SurveillanceType surveillanceType, SurveillanceContext surveillanceContext)
{
var sType = SurveillanceTypeMap[surveillanceType];
var methodInfo = _surveillances.GetType().GetMethod("IsSurveillanceNoUnique");
methodInfo = methodInfo.MakeGenericMethod(sType);
var unique = (bool) methodInfo.Invoke(_surveillances, new object[] {surveillanceNo, surveillanceContext});
return unique;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment