Example #1
0
        /// <summary>
        /// * 从程序集生成对象
        /// </summary>
        /// <typeparam name="TObject">返回类型</typeparam>
        /// <param name="typeName">反射类型名称</param>
        /// <param name="assemblyName">程序集名称</param>
        /// <returns></returns>
        public static TObject CreateObject <TObject>(string typeName, string assemblyName) where TObject : class
        {
            TObject res = null;

            res = ClassLibraryObjectFactory.GetAssembly(assemblyName).CreateInstance(typeName) as TObject;

            return(res);
        }
Example #2
0
        /// <summary>
        /// * 根据类型名称生成对象
        /// </summary>
        /// <typeparam name="TObject">类型</typeparam>
        /// <param name="typeName">类型名称</param>
        /// <param name="parameters">构造函数参数</param>
        /// <returns></returns>
        public static TObject CreateObject <TObject>(string typeName, params object[] parameters) where TObject : class
        {
            TObject res = null;

            res = ClassLibraryObjectFactory.GetAssemblyByType(typeName).CreateInstance(typeName, true, BindingFlags.CreateInstance, null, parameters, null, null) as TObject;

            return(res);
        }
Example #3
0
        /// <summary>
        /// * 从程序集生成对象
        /// </summary>
        /// <typeparam name="TObject">返回类型</typeparam>
        /// <returns></returns>
        public static TObject CreateObject <TObject>() where TObject : class
        {
            Type type = typeof(TObject);

            return(ClassLibraryObjectFactory.CreateObject <TObject>(type.FullName));
        }
Example #4
0
 /// <summary>
 /// * 获得一个类型
 /// </summary>
 /// <param name="typeName">类型名称</param>
 /// <param name="assemblyName">类型所在程序集</param>
 /// <returns></returns>
 public static Type GetType(string typeName, string assemblyName)
 {
     return(ClassLibraryObjectFactory.GetAssembly(assemblyName).GetType(typeName));
 }