コード例 #1
0
        public CodeMemberMethod CreateApiFunction(WebApiDescription description, IPoco2Client poco2TsGen, bool stringAsString)
        {
            this.Description    = description;
            this.Poco2TsGen     = poco2TsGen;
            this.StringAsString = stringAsString;

            MethodName = TsCodeGenerationOptions.Instance.CamelCase ? Fonlow.Text.StringExtensions.ToCamelCase(description.ActionDescriptor.ActionName) : description.ActionDescriptor.ActionName;
            if (MethodName.EndsWith("Async"))
            {
                MethodName = MethodName.Substring(0, MethodName.Length - 5);                //HTTP does not care about the server side async.
            }
            ReturnType = description.ResponseDescription?.ResponseType ?? description.ActionDescriptor.ReturnType;

            //create method
            Method = CreateMethodName();

            CreateDocComments();

            switch (description.HttpMethod)
            {
            case "GET":
            case "DELETE":
            case "POST":
            case "PUT":
                RenderImplementation();
                break;

            default:
                Trace.TraceWarning("This HTTP method {0} is not yet supported", description.HttpMethod);
                break;
            }

            return(Method);
        }