private void ProcessRouteParameter(string param) { param = param.Trim('{', '}'); PropertyInfo property = null; try { property = RouteType.GetProperty(param); } catch (Exception) { } if (property == null) { MethodParameters.Add("\n /* CANNOT FIND " + param + " */\n "); } else { param = param.ToCamelCase(); ProcessClrProperty(property, true); // Uri Encode string parameters. if (property.GetGetMethod().ReturnType == typeof(string)) { UrlPath.Add("encodeURIComponent(" + param + ")"); } else { UrlPath.Add(param); } } }
private MethodParameters GetMethodParameters(string method) { MethodParameters parameters = new MethodParameters(); switch (method) { case "RedirectWorklistItem": { parameters.Add(new MethodParameter("UserName", "System.String", SoType.Text, new MetaData("User Name", ""))); break; } case "RedirectManagedUserWorklistItem": { parameters.Add(new MethodParameter("ManagedUserName", "System.String", SoType.Text, new MetaData("Managed User Name", ""))); parameters.Add(new MethodParameter("UserName", "System.String", SoType.Text, new MetaData("User Name", ""))); break; } } return(parameters); }
/// <summary> /// Generates typescript code for a given property /// </summary> /// <param name="property"></param> /// <param name="IsRouteParam"></param> private void ProcessClrProperty(PropertyInfo property, bool IsRouteParam = false) { PropertiesProcessed.Add(property.Name); // TODO: Add comments for ApiMember properties var docAttr = property.GetCustomAttribute <ApiMemberAttribute>(); Type returnType = property.GetMethod.ReturnType; // Optional parameters if (!IsRouteParam && (returnType.IsNullableType() || returnType.IsClass()) && (docAttr == null || !docAttr.IsRequired)) // Optional param. Could be string or a DTO type. { /*MethodParametersOptional.Add(property.Name.ToCamelCase() + "?: " + _CodeGenerator.DetermineTsType(returnType)); */ if (docAttr != null) { RouteInputPropertyLines.Add(EmitComment(docAttr)); } RouteInputPropertyLines.Add(property.Name + "?: " + _CodeGenerator.DetermineTsType(returnType, true) + ";"); } else // Required parameter { if (!IsRouteParam) { if (docAttr != null) { RouteInputPropertyLines.Add(EmitComment(docAttr)); } RouteInputHasOnlyOptionalParams = false; RouteInputPropertyLines.Add(property.Name + ": " + _CodeGenerator.DetermineTsType(returnType, true) + ";"); } else { MethodParameters.Add(property.Name.ToCamelCase() + ": " + _CodeGenerator.DetermineTsType(returnType, true)); } } ParamsWritten++; }
private MethodParameters GetMethodParameters(string method) { MethodParameters parameters = new MethodParameters(); switch (method) { case "RedirectWorklistItem": { parameters.Add(new MethodParameter("UserName", "System.String", SoType.Text, new MetaData("User Name", ""))); break; } case "RedirectManagedUserWorklistItem": { parameters.Add(new MethodParameter("ManagedUserName", "System.String", SoType.Text, new MetaData("Managed User Name", ""))); parameters.Add(new MethodParameter("UserName", "System.String", SoType.Text, new MetaData("User Name", ""))); break; } } return parameters; }