vendredi 10 mai 2019

Get method info of extension method

I have an instance of:

IDbConnection db;

And there exists an extension method for this type:

public static bool TableExists<T>(this IDbConnection dbConn)
{
  // code omitted
}

With reflection how to I get the MethodInfo of TableExists?

I tried:

var tableMethod = _db.GetType().GetMethod("TableExists", BindingFlags.Public | BindingFlags.Static);

But it returns null. When I do _db.GetType().GetMethod() I can see the extension method is not in the collection.

What is the way to get MethodInfo for the extension method?





Aucun commentaire:

Enregistrer un commentaire