public bool isCollection(object o)
{
return typeof(ICollection).IsAssignableFrom(o.GetType())
|| typeof(ICollection<>).IsAssignableFrom(o.GetType());
}
{
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);
}
{
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);
}
{
return type.GetProperty(propertyName, BindingFlags.Public
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy);
}