I've got a problem invoking with these classes:
class Container
{
IARepo a = new ARepo();
IBRepo b = new BRepo();
ICRepo c = new CRepo();
}
interface ARepo:Repo<ABase>, IARepo
{
}
interface IARepo: IRepo<ABase>
{
}
interface IRepo<T>
{
GetAll();
}
class Repo<T> : IRepo<T>
{
GetAll();
}
I have to iterate over a, b and c to find a specific member of the container and call GetAll() via reflections on it.
What i do at the moment is:
PropertyInfo[] properties = typeof(container).GetProperties();
foreach (PropertyInfo property in properties)
{
if (property.Name.Equals(NAME OF REPOSITORY))
{
//Access GetAll() for the specified property
}
}
Using MethodInfo
I can't access GetAll()
as it is declared in a base type of the member.
Could you enlighten me on how to do it and why sour solution works?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire