Bumped package version to 1.5.0, changed Program.cs a little of the example. Improved the Javascript Client generator by exporting all types and changing enum to behave in a more useful way.
This commit is contained in:
@ -11,61 +11,61 @@ using System.Collections;
|
||||
|
||||
namespace MontoyaTech.Rest.Net.Example
|
||||
{
|
||||
public class BaseUser
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public char FirstInitial;
|
||||
|
||||
public UserRole Role { get; set; }
|
||||
|
||||
public List<Permission> Permissions;
|
||||
|
||||
public class Permission
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public Types Type;
|
||||
|
||||
public enum Types { Read, Write }
|
||||
}
|
||||
}
|
||||
|
||||
[RouteTypeName("UserDto")]
|
||||
public class User : BaseUser
|
||||
{
|
||||
public PlatformID MachineType;
|
||||
|
||||
public string Name = null;
|
||||
|
||||
public List<string> List = null;
|
||||
|
||||
public string[] Array = null;
|
||||
|
||||
public ulong Property { get; set; }
|
||||
|
||||
public User() { }
|
||||
|
||||
public User(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public enum UserRole : byte
|
||||
{
|
||||
Unknown = 0,
|
||||
Admin = 2,
|
||||
User = 1
|
||||
}
|
||||
|
||||
public class IncludedType
|
||||
{
|
||||
public int Test;
|
||||
}
|
||||
|
||||
public class Program
|
||||
{
|
||||
public class BaseUser
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public char FirstInitial;
|
||||
|
||||
public UserRole Role { get; set; }
|
||||
|
||||
public List<Permission> Permissions;
|
||||
|
||||
public class Permission
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public Types Type;
|
||||
|
||||
public enum Types { Read, Write }
|
||||
}
|
||||
}
|
||||
|
||||
[RouteTypeName("UserDto")]
|
||||
public class User : BaseUser
|
||||
{
|
||||
public PlatformID MachineType;
|
||||
|
||||
public string Name = null;
|
||||
|
||||
public List<string> List = null;
|
||||
|
||||
public string[] Array = null;
|
||||
|
||||
public ulong Property { get; set; }
|
||||
|
||||
public User() { }
|
||||
|
||||
public User(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public enum UserRole : byte
|
||||
{
|
||||
Unknown = 0,
|
||||
Admin = 2,
|
||||
User = 1
|
||||
}
|
||||
|
||||
public class IncludedType
|
||||
{
|
||||
public int Test;
|
||||
}
|
||||
|
||||
public static RouteFileCache FileCache = new RouteFileCache(100 * 1024 * 1024);
|
||||
|
||||
public static void Main(string[] args)
|
||||
@ -87,16 +87,15 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
|
||||
string code = listener.GenerateCSharpClient();
|
||||
|
||||
File.WriteAllText("Client.cs", code);
|
||||
File.WriteAllText("Client.cs", listener.GenerateCSharpClient());
|
||||
|
||||
Console.WriteLine(code);
|
||||
Console.WriteLine();
|
||||
File.WriteAllText("Client.js", listener.GenerateJavascriptClient());
|
||||
|
||||
string staticCode = listener.GenerateCSharpClient("StaticClient", staticCode: true);
|
||||
File.WriteAllText("StaticClient.cs", listener.GenerateCSharpClient("StaticClient", staticCode: true));
|
||||
|
||||
File.WriteAllText("Client.Static.cs", staticCode);
|
||||
File.WriteAllText("StaticClient.js", listener.GenerateJavascriptClient("StaticClient", staticCode: true));
|
||||
|
||||
Console.WriteLine(staticCode);
|
||||
Console.WriteLine("Generated Client.cs, Client.js, StaticClient.cs, StaticClient.js");
|
||||
|
||||
listener.RequestPreProcessEvent += (HttpListenerContext context) => {
|
||||
Console.WriteLine($"[{context.Request.HttpMethod}] Request start: " + context.Request.RawUrl);
|
||||
|
Reference in New Issue
Block a user