Example #1
0
        public object ParseParameter(Type paramType, ParamMetadata pinfo, bool isArray, string val)
        {
            var dataType = pinfo.dataType;

            if (isArray && val != null)
            {
                var arr = this.Deserialize <string[]>(val);
                if (arr == null)
                {
                    return(null);
                }
                var list = (IList)typeof(DataHelper).GetMethod("CreateList", BindingFlags.NonPublic | BindingFlags.Static)
                           .MakeGenericMethod(paramType.GetElementType())
                           .Invoke(null, new object[] {});
                foreach (var v in arr)
                {
                    list.Add(ParseParameter(paramType.GetElementType(), pinfo, false, v));
                }

                return(typeof(DataHelper).GetMethod("CreateArray", BindingFlags.NonPublic | BindingFlags.Static)
                       .MakeGenericMethod(paramType.GetElementType())
                       .Invoke(null, new object[] { list }));
            }

            return(this.valueConverter.DeserializeValue(paramType, dataType, pinfo.dateConversion, val));
        }
Example #2
0
 private IEnumerable ToEnumerable(Type elementType, ParamMetadata pinfo, string[] arr)
 {
     foreach (string v in arr)
     {
         yield return(ParseParameter(elementType, pinfo, false, v));
     }
 }
Example #3
0
 private string _CreateParamSignature(ParamMetadata paramInfo, DotNet2TS dotNet2TS)
 {
     return(string.Format("{0}{1}: {2}{3};", paramInfo.name, paramInfo.isNullable ? "?" : "",
                          paramInfo.dataType == DataType.None
             ? dotNet2TS.RegisterType(paramInfo.GetParameterType())
             : DotNet2TS.DataTypeToTypeName(paramInfo.dataType),
                          paramInfo.dataType != DataType.None && paramInfo.isArray ? "[]" : ""));
 }
Example #4
0
 public static ParamMetadata GetDocs(this HttpParameterDescriptor param, XPathNavigator actionDocs)
 {
     var rtn = new ParamMetadata
         {
             Name = param.ParameterName,
             Comment = Utils.GetNodeValue(actionDocs, "param"),
             Type = Utils.GetCleanTypeName(param.ParameterType)
         };
     
     return rtn;
 }
Example #5
0
        public static ParamMetadata GetDocs(this HttpParameterDescriptor param, XPathNavigator actionDocs)
        {
            var rtn = new ParamMetadata
            {
                Name    = param.ParameterName,
                Comment = Utils.GetNodeValue(actionDocs, "param"),
                Type    = Utils.GetCleanTypeName(param.ParameterType)
            };

            return(rtn);
        }
Example #6
0
        private object ParseArray(Type paramType, ParamMetadata pinfo, string val)
        {
            string[] arr = Deserialize <string[]>(val);

            if (arr == null)
            {
                return(null);
            }

            Type elementType = paramType.GetElementType();

            IEnumerable data = ToEnumerable(elementType, pinfo, arr);

            return(data.ToArray(elementType));
        }
Example #7
0
        public object GetValue(string name, MethodDescription methodDescription, IDataHelper dataHelper)
        {
            MethodParameter par = parameters.Where(p => p.name == name).FirstOrDefault();

            if (par == null)
            {
                return(null);
            }

            ParamMetadata paraminfo = methodDescription.parameters.Where(p => p.name == name).FirstOrDefault();

            if (paraminfo == null)
            {
                throw new DomainServiceException(string.Format("Method: {0} has no parameter with a name: {1}",
                                                               methodDescription.methodName, name));
            }
            return(dataHelper.ParseParameter(paraminfo.GetParameterType(), paraminfo, paraminfo.isArray,
                                             par.value));
        }
Example #8
0
 public object ParseParameter(Type paramType, ParamMetadata pinfo, bool isArray, string val)
 {
     return((isArray && val != null) ? ParseArray(paramType, pinfo, val) : _valueConverter.DeserializeValue(paramType, pinfo.dataType, pinfo.dateConversion, val));
 }