예제 #1
0
        /// <summary>
        /// 得到实体类的值
        /// </summary>
        /// <param name="paramName">当前参数的名称</param>
        /// <param name="paramType">当前参数的类型</param>
        /// <param name="currentHttpRequest">当前的请求详情</param>
        /// <returns></returns>
        public override object GetValue(string paramName,Type paramType,HttpRequestDescription currentHttpRequest)
        {
            base.GetValue(paramName, paramType,currentHttpRequest);

            //得到该实体类的属性
            PropertyInfo[] propertys = paramType.GetPropertyInfos(GetRequestDataStrategy.bindingFlags);

            object t = paramType.CreateInstace();
            for (int i = 0; i < propertys.Length; i++)
            {
                if (propertys[i].CanWrite)
                {
                    //如果为可写时   尝试再次使用策略进行转化
                    GetRequestDataContext context = new GetRequestDataContext(propertys[i].Name, propertys[i].PropertyType, currentHttpRequest);

                    object obj = context.GetValue();
                    propertys[i].SetValue(t, obj, null);
                }
                //不是  还不是简单地类型 就不再进行操作 直接舍弃
            }
            return t;
        }
예제 #2
0
        /// <summary>
        /// 得到实体类的值
        /// </summary>
        /// <param name="paramName">当前参数的名称</param>
        /// <param name="paramType">当前参数的类型</param>
        /// <param name="currentHttpRequest">当前的请求详情</param>
        /// <returns></returns>
        public override object GetValue(string paramName, Type paramType, HttpRequestDescription currentHttpRequest)
        {
            base.GetValue(paramName, paramType, currentHttpRequest);

            //得到该实体类的属性
            PropertyInfo[] propertys = paramType.GetPropertyInfos(GetRequestDataStrategy.bindingFlags);

            object t = paramType.CreateInstace();

            for (int i = 0; i < propertys.Length; i++)
            {
                if (propertys[i].CanWrite)
                {
                    //如果为可写时   尝试再次使用策略进行转化
                    GetRequestDataContext context = new GetRequestDataContext(propertys[i].Name, propertys[i].PropertyType, currentHttpRequest);

                    object obj = context.GetValue();
                    propertys[i].SetValue(t, obj, null);
                }
                //不是  还不是简单地类型 就不再进行操作 直接舍弃
            }
            return(t);
        }
예제 #3
0
 /// <summary>
 /// 得到参数的值
 /// </summary>
 /// <param name="parameterInfo"></param>
 /// <returns></returns>
 private object GetValue(ParameterInfo parameterInfo)
 {
     GetRequestDataContext context = new GetRequestDataContext(parameterInfo.Name, parameterInfo.ParameterType,this._currentHttpRequest);
     return context.GetValue();
 }