/// <summary>
/// 创建实例 支持泛型的创建
/// </summary>
/// <typeparam name="T">此处T形如 Common<User></typeparam>
/// <returns></returns>
public static T Create<T>()
{
var t = typeof (T);
if (t.IsInterface)
{
var name = string .Format("{0}.{1}", AssemblyStr, t.Name.TrimStart('I' ));
var type = GetAssembly().GetType(name);
if (type.IsGenericType)
{
var typeArgument = t.GetGenericArguments().FirstOrDefault(); //单个泛型形参
var genericType = type.MakeGenericType(typeArgument);
object O = (T)Activator .CreateInstance(genericType);
}
else
{
return (T)Activator .CreateInstance(type);
}
}
return default (T);
}