public ClientApiFunctionGen(SharedContext sharedContext, WebApiDescription description, Poco2Client.Poco2CsGen poco2CsGen, bool stringAsString, bool forAsync, bool diFriendly, bool useEnsureSuccessStatusCodeEx) { this.description = description; this.sharedContext = sharedContext; this.poco2CsGen = poco2CsGen; this.forAsync = forAsync; this.stringAsString = stringAsString; this.diFriendly = diFriendly; statementOfEnsureSuccessStatusCode = useEnsureSuccessStatusCodeEx ? "EnsureSuccessStatusCodeEx" : "EnsureSuccessStatusCode"; methodName = description.ActionDescriptor.ActionName; if (methodName.EndsWith("Async")) { methodName = methodName.Substring(0, methodName.Length - 5); } returnType = description.ResponseDescription?.ResponseType ?? description.ActionDescriptor.ReturnType; returnTypeIsStream = returnType != null && ((returnType.FullName == typeNameOfHttpResponseMessage) || (returnType.FullName == typeOfIHttpActionResult) || (returnType.FullName == typeOfIActionResult) || (returnType.FullName == typeOfActionResult) || (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.IActionResult")) || // .net core is not translating Task<IActionResult> properly. (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.IHttpActionResult")) || (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.ActionResult")) ); returnTypeIsDynamicObject = returnType != null && returnType.FullName != null && returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[System.Object"); }
public static CodeMemberMethod Create(SharedContext sharedContext, WebApiDescription description, Poco2Client.Poco2CsGen poco2CsGen, bool stringAsString, bool forAsync, bool diFriendly, bool useEnsureSuccessStatusCodeEx) { var gen = new ClientApiFunctionGen(sharedContext, description, poco2CsGen, stringAsString, forAsync, diFriendly, useEnsureSuccessStatusCodeEx); return(gen.CreateApiFunction()); }
public CodeMemberMethod CreateApiFunction(WebApiDescription description, Fonlow.Poco2Client.IPoco2Client poco2TsGen, bool stringAsString) { this.Description = description; this.Poco2TsGen = poco2TsGen; this.stringAsString = stringAsString; NethodName = TsCodeGenerationOptions.Instance.CamelCase ? Fonlow.Text.StringExtensions.ToCamelCase(description.ActionDescriptor.ActionName) : description.ActionDescriptor.ActionName; if (NethodName.EndsWith("Async")) { NethodName = NethodName.Substring(0, NethodName.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); }
public ClientApiFunctionGen(SharedContext sharedContext, WebApiDescription description, Fonlow.Poco2Client.IPoco2Client poco2CsGen) { this.description = description; this.sharedContext = sharedContext; this.poco2CsGen = poco2CsGen; methodName = description.ActionDescriptor.ActionName; if (methodName.EndsWith("Async")) { methodName = methodName.Substring(0, methodName.Length - 5); } returnType = description.ResponseDescription?.ResponseType ?? description.ActionDescriptor.ReturnType; }
public ClientApiFunctionGen(SharedContext sharedContext, WebApiDescription description, Fonlow.Poco2Client.IPoco2Client poco2CsGen, bool stringAsString, bool forAsync = false) { this.description = description; this.sharedContext = sharedContext; this.poco2CsGen = poco2CsGen; this.forAsync = forAsync; this.stringAsString = stringAsString; methodName = description.ActionDescriptor.ActionName; if (methodName.EndsWith("Async")) { methodName = methodName.Substring(0, methodName.Length - 5); } returnType = description.ResponseDescription?.ResponseType ?? description.ActionDescriptor.ReturnType; returnTypeIsStream = returnType != null && ((returnType.FullName == typeNameOfHttpResponseMessage) || (returnType.FullName == typeOfIHttpActionResult) || (returnType.FullName == typeOfIActionResult) || (returnType.FullName == typeOfActionResult) || (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.IActionResult")) || // .net core is not translating Task<IActionResult> properly. (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.IHttpActionResult")) || (returnType.FullName.StartsWith("System.Threading.Tasks.Task`1[[Microsoft.AspNetCore.Mvc.ActionResult")) ); }
public static CodeMemberMethod Create(SharedContext sharedContext, WebApiDescription description, Fonlow.Poco2Client.IPoco2Client poco2CsGen, bool forAsync = false) { var gen = new ClientApiFunctionGen(sharedContext, description, poco2CsGen); return(gen.CreateApiFunction(forAsync)); }
public static CodeMemberMethod Create(WebApiDescription description, Poco2Client.Poco2CsGen poco2CsGen, CodeGenOutputs settings, bool forAsync) { var gen = new ClientApiFunctionGen(description, poco2CsGen, settings, forAsync); return(gen.CreateApiFunction()); }