I don't understand why GetMethod
return null
- two times at method1
and method
Type model = AssemblyHelper.GetTypeByClassName(Assembly.GetExecutingAssembly(), modelName + MappingColums.Tokens.Validation); // MappingColums.Tokens.Validation = "Validation"
for testing purpose I try get method twice:
MethodInfo method1 = model.GetType().GetMethod(MappingColums.Tokens.Get + modelName); // MappingColums.Tokens.Get + modelName = "Get" + "Product"
MethodInfo method = model.GetType().GetMethods().FirstOrDefault(x => x.Name == MappingColums.Tokens.Get + modelName && x.GetParameters().Count() == 0);
object result = method.Invoke(model, null);
below class and method that I want to use by reflection.
public class ProductValidation
{
private IProductRepository repositoryProduct;
public ProductValidation(IProductRepository repoProduct)
{
repositoryProduct = repoProduct;
}
public ICollection<Product> GetProduct()
{
return repositoryProduct.Products.ToList();
}
}
I do not know if it matters, but I'm using ASP.NET Core MVC
. Where I debug Type model
just behind AssemblyHelper.GetTypeByClassName
there is at Declared Methods: {System.Collections.Generic.ICollection1[AureliaCMS.Models.Entities.Product] GetProduct()}
Please give me advice where to look up for issue.
Aucun commentaire:
Enregistrer un commentaire