예제 #1
0
        /// <summary>
        /// 如果保存的是Type信息,则转换成Type
        /// </summary>
        /// <param name="throwError">是否抛出异常</param>
        /// <returns>Type</returns>
        Type IConverting.ToType(bool throwError)
        {
            Type type = null;

            try
            {
                type = UtilityType.CreateType(this.GetType().Assembly, this.ConvertingValue, throwError);
            }
            catch (Exception e)
            {
                if (throwError)
                {
                    throw new GeanException("转换成Type时错误", e);
                }
            }
            return(type);
        }
예제 #2
0
 /// <summary>
 /// 根据值创建对象
 /// </summary>
 /// <param name="expectedType">期望的类型</param>
 /// <param name="throwError">是否抛出异常</param>
 /// <param name="paramTypes">构造函数的参数类型列表</param>
 /// <param name="paramValues">构造函数的参数列表</param>
 /// <returns>对象</returns>
 object IConverting.ToObject(Type expectedType, bool throwError, Type[] paramTypes, object[] paramValues)
 {
     return(UtilityType.CreateObject(this.GetType().Assembly, this.ConvertingValue, expectedType, throwError, paramTypes, paramValues));
 }
예제 #3
0
 /// <summary>
 /// 根据值创建对象
 /// </summary>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns>对象</returns>
 object IConverting.ToObject(params object[] parameters)
 {
     return(UtilityType.CreateObject(this.GetType().Assembly, this.ConvertingValue, null, true, parameters));
 }
예제 #4
0
 /// <summary>
 /// 从程序集中获取程序集实例中具有指定名称的 System.Type 对象。
 /// 当输入assignableFromType时判断该Type是否是从assignableFromType继承。
 /// assignableFromType可以为Null,为Null时不作判断。
 /// </summary>
 /// <param name="assembly">指定的程序集</param>
 /// <param name="classname">类型的全名</param>
 /// <returns>如找到返回该类型,未找到返Null</returns>
 public static Type Load(Assembly assembly, string classname)
 {
     return(UtilityType.Load(assembly, classname, null));
 }