Using reflection to find interfaces implemented

前端 未结 3 692
既然无缘
既然无缘 2020-12-06 00:06

I have the following case:

public interface IPerson { .. }    
public class Person : IPerson { .. }    
public class User : Person { .. }

3条回答
  •  一整个雨季
    2020-12-06 00:37

    var control = _container.Resolve(objType); 
    var prop = viewType.GetProperty("SomeUser");
    if ((prop != null) && (prop.PropertyType.GetInterfaces().Contains(typeof(IPerson))) 
    { .. }
    

提交回复
热议问题