Exemple #1
0
        public static MethodDescription FromMethodInfo(MethodInfo methodInfo, bool isQuery)
        {
            Type returnType           = methodInfo.ReturnType;
            bool isVoid               = returnType == typeof(void);
            MethodDescription invInfo = new MethodDescription();

            invInfo.methodInfo = methodInfo;
            invInfo.methodName = methodInfo.Name;
            invInfo.isQuery    = isQuery;

            if (!isVoid)
            {
                invInfo.methodResult = true;
            }
            //else Result is Converted to JSON
            ParameterInfo[] paramsInfo = methodInfo.GetParameters();
            for (var i = 0; i < paramsInfo.Length; ++i)
            {
                if (isQuery && paramsInfo[i].ParameterType == typeof(GetDataInfo))
                {
                    continue;
                }
                ParamMetadataInfo param = ParamMetadataInfo.FromParamInfo(paramsInfo[i]);
                param.ordinal = i;
                invInfo.parameters.Add(param);
            }
            return(invInfo);
        }
Exemple #2
0
        /// <summary>
        /// Extracts from ParameterInfo all information about method parameter
        /// returns InvokeParamInfo
        /// </summary>
        /// <param name="pinfo"></param>
        /// <returns></returns>
        public static ParamMetadataInfo FromParamInfo(ParameterInfo pinfo)
        {
            Type ptype = pinfo.ParameterType;

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

            res.isNullable    = DataHelper.IsNullableType(ptype);
            res.name          = pinfo.Name;
            res.ParameterType = ptype;
            Type realType = null;

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

            res.dataType = DataHelper.DataTypeFromType(realType, out isArray);
            res.isArray  = isArray;
            return(res);
        }
 /// <summary>
 /// Extracts from ParameterInfo all information about method parameter
 /// returns InvokeParamInfo
 /// </summary>
 /// <param name="pinfo"></param>
 /// <returns></returns>
 public static ParamMetadataInfo FromParamInfo(ParameterInfo pinfo)
 {
     Type ptype = pinfo.ParameterType;
     if (pinfo.IsOut)
         throw new DomainServiceException("Out parameters are not supported in service methods");
     ParamMetadataInfo res = new ParamMetadataInfo();
     res.isNullable = DataHelper.IsNullableType(ptype);
     res.name = pinfo.Name;
     res.ParameterType = ptype;
     Type realType = null;
     if (!res.isNullable)
         realType = ptype;
     else
         realType = Nullable.GetUnderlyingType(ptype);
     object[] dtops = pinfo.GetCustomAttributes(typeof(DateOptionAttribute), false);
     if (dtops.Length > 0) {
        res.dateConversion = (dtops[0] as DateOptionAttribute).dateConversion;
     }
     bool isArray = false;
     res.dataType = DataHelper.DataTypeFromType(realType, out isArray);
     res.isArray = isArray;
     return res;
 }