public void ClassUtil_BuildGenericTypeInstance() { var obj = ClassUtil.BuildGenericTypeInstance(typeof(ClassUtilTest <>), typeof(string)); Assert.IsTrue(obj is ClassUtilTest <string>); obj = ClassUtil.BuildGenericTypeInstance(typeof(ClassUtilTest <>), new Type[] { typeof(string) }, "abc"); Assert.IsTrue(obj is ClassUtilTest <string>); }
/// <summary> /// 允许删除的判断标注; /// </summary> /// <param name="relateType"></param> /// <param name="propertyName"></param> public AllowDeleteAttribute(Type relateType, string propertyName) { this.relateType = relateType; this.propertyName = propertyName; if (propertyName == null) { } allowDelete = ClassUtil.BuildGenericTypeInstance(typeof(GenericAllowDelete <>), new Type[] { relateType }, propertyName) as IAllowDelete; }