vendredi 15 juillet 2016

C# Reflection - GetMethod

I'm working on a project where a System.Web.Helpers.Webgrid has been used as a bas class for a new grid I beleive that it uses reflection to invoke private methds of the base class.

Could someone please clarify....... In the code below, seeing as GetDefaultColumnsMethod returns something, can I presume that System.Web.Helpers.WebGrid has a method on it named "GetDefaultColumns"?

private MethodInfo GetDefaultColumnsMethod 
{
    get { return typeof(System.Web.Helpers.WebGrid).GetMethod("GetDefaultColumns", BindingFlags.Instance | BindingFlags.NonPublic); }
}

private IEnumerable<WebGridColumn> GetDefaultColumns(IEnumerable<string> exclusions)
{
    return (IEnumerable <WebGridColumn>)GetDefaultColumnsMethod.Invoke((System.Web.Helpers.WebGrid)this, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { exclusions }, null);
}





Aucun commentaire:

Enregistrer un commentaire