Working on C# client code generation.

This commit is contained in:
2023-02-04 08:26:09 -08:00
parent 19ccdb9026
commit 6bb01464e7
7 changed files with 298 additions and 9 deletions

View File

@ -34,7 +34,9 @@ namespace MontoyaTech.Rest.Net.Example
new Route(HttpRequestMethod.Get, "/json", Json)
);
Console.WriteLine(CodeGenerator.GenerateCSharpClient(listener.Routes));
string code = CodeGenerator.GenerateCSharpClient(listener.Routes);
Console.WriteLine(code);
Console.ReadLine();
@ -61,24 +63,35 @@ namespace MontoyaTech.Rest.Net.Example
}
[RouteGroup("Test")]
[RouteResponse(typeof(string))]
public static HttpListenerResponse Status(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText("Everything is operational. 👍");
}
[RouteGroup("Test")]
[RouteResponse(typeof(string))]
public static HttpListenerResponse Add(HttpListenerContext context, double a, double b)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText((a + b).ToString());
}
[RouteGroup("Test")]
[RouteResponse(typeof(string))]
public static HttpListenerResponse Signup(HttpListenerContext context, User user)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText("User:" + user.Name);
}
[RouteGroup("Test")]
[RouteRequest(typeof(User))]
public static HttpListenerResponse SignupRequest(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK);
}
[RouteGroup("Test")]
[RouteResponse(typeof(User))]
public static HttpListenerResponse Json(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(new User("Rest.Net"));