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)); }
private IEnumerable ToEnumerable(Type elementType, ParamMetadata pinfo, string[] arr) { foreach (string v in arr) { yield return(ParseParameter(elementType, pinfo, false, v)); } }
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 ? "[]" : "")); }
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; }
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); }
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)); }
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)); }
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)); }