/// <summary>
        /// 转换配置值类型
        /// </summary>
        /// <typeparam name="T">目标类型</typeparam>
        /// <param name="value">要转换的配置值</param>
        /// <returns>转换后的配置值</returns>
        private static T CastTo <T>(ConfigurationValue value)
        {
            var type = typeof(T);


            if (type.IsValueType)
            {
                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    if (value == null || value is NullValue)
                    {
                        return(default(T));
                    }

                    else
                    {
                        return((T)value.CastTo(Nullable.GetUnderlyingType(type)));
                    }
                }


                if (value == null || value is NullValue)
                {
                    throw new InvalidCastException(string.Format("cannot convert null value to type \"{0}\"", type.AssemblyQualifiedName));
                }
            }


            if (value == null || value is NullValue)
            {
                return(default(T));
            }


            return((T)value.CastTo(type));
        }
 public DynamicProxy(Expression expression, ConfigurationValue obj)
     : base(expression, BindingRestrictions.GetTypeRestriction(expression, obj.GetType()), obj)
 {
 }