反射判断 某个对象 是否 是泛型集合的类型
 public bool isCollection(object o) 
    { 
        
return typeof(ICollection).IsAssignableFrom(o.GetType()) 
            
|| typeof(ICollection<>).IsAssignableFrom(o.GetType()); 
    } 

 获取类实例

        public static object Load(string assembly, string className)
        {
            
return Assembly.Load(assembly).CreateInstance(className);
        }

 

获取指定属性

        public static PropertyInfo GetPropertyByName(Type type, string propertyName)
        {
            
return type.GetProperty(propertyName, BindingFlags.Public
                
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy);
        }

相关文章:

  • 2021-11-05
  • 2021-11-05
  • 2021-11-05
  • 2021-04-01
  • 2021-08-11
  • 2021-04-28
  • 2021-10-17
  • 2021-11-02
猜你喜欢
  • 2021-11-21
  • 2021-08-21
  • 2021-12-15
  • 2021-10-01
  • 2021-10-06
  • 2021-06-21
  • 2021-12-03
  • 2021-10-16
相关资源
相似解决方案