mercredi 6 mai 2020

Avoid AmbiguousMethod exception, but GetMethod returns null even with parameter list added

This question has been asked before but I can't figure it out for my case.

I get null from the following code:

typeof(SettingsController)
    .GetMethod("GetById", new[] { typeof(Guid?), typeof(IValidator<>), typeof(HttpStatusCode) });

I need to pass the parameter list because I've got two methods with the same name in the base class of SettingsController:

public T GetById<T>(Guid? id, IValidator<T> validator, HttpStatusCode statusCode = HttpStatusCode.OK)

public T GetById<T>(Guid? id, string route, IValidator<T> validator, HttpStatusCode statusCode = HttpStatusCode.OK)

What am I missing?





Aucun commentaire:

Enregistrer un commentaire