示例#1
0
        /// <summary>
        /// Extracts from ParameterInfo all information about method parameter
        /// </summary>
        /// <returns>ParamMetadataInfo</returns>
        public static ParamMetadataInfo FromParamInfo(ParameterInfo pinfo, IDataHelper dataHelper)
        {
            Type ptype = pinfo.ParameterType;

            if (pinfo.IsOut)
            {
                throw new DomainServiceException("Out parameters are not supported in service methods");
            }
            ParamMetadataInfo paramInfo = new ParamMetadataInfo();

            paramInfo.isNullable    = dataHelper.IsNullableType(ptype);
            paramInfo.name          = pinfo.Name;
            paramInfo.ParameterType = ptype;
            Type realType = null;

            if (!paramInfo.isNullable)
            {
                realType = ptype;
            }
            else
            {
                realType = Nullable.GetUnderlyingType(ptype);
            }
            object[] dtops = pinfo.GetCustomAttributes(typeof(DateOptionAttribute), false);
            if (dtops.Length > 0)
            {
                paramInfo.dateConversion = (dtops[0] as DateOptionAttribute).dateConversion;
            }
            bool isArray = false;

            paramInfo.dataType = dataHelper.DataTypeFromType(realType, out isArray);
            paramInfo.isArray  = isArray;
            return(paramInfo);
        }