NetStitch is a Http RPC Framework built on .NetFramework/.NETCore.
It is provides simple and easy Http WebApi Call for C#.
This Framework is composed of two projects NetStitch.Server and NetStitch.Client.
NetStitch.Server is a Middleware of ASP.NET Core.
PM>Install-Package NetStitch.Server
NetStitch.Server Packages ├─build │ └NetStitch.Server.targets └─lib └DLLs
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup>
<DefineConstants>$(DefineConstants);___server___</DefineConstants>
<NoWarn>1998</NoWarn>
</PropertyGroup>
</Project>
1.Add ASP.Net Core StartUp.
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseNetStitch(typeof(Startup));
}
}
2.Implementation of "If Directive Approach" Interface .
public interface Interface : INetStitchContract
{
[Operation]
ValueTask<int> ValueTaskMethodAsync
(int a, int b
#if !___server___
, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)
#endif
);
}
public class MyClass : Interface
{
public async ValueTask<int> ValueTaskMethodAsync(int a, int b)
{
return a + b;
}
}
NetStitch.Client is a RPC Client of NetStitch.Server.
PM>Install-Package NetStitch.Client
new NetStitch.NetStitchClient(EndPointUrl).Create<Interface>().Method(Parameter);
NetStitch uses #if preprocessor directive to match the definitions of client and server interfaceses.
Original Method
public interface Interface
{
ValueTask<int> ValueTaskMethodAsync(int a, int b);
}
If Directive Approach
public interface Interface : INetStitchContract
{
[Operation]
ValueTask<int> ValueTaskMethodAsync
(int a, int b
#if !___server___
, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)
#endif
);
}
ReturnType | Original Method | If Directive Approach |
---|---|---|
Task | Task MethodAsync(); |
|
ValueTask<T> | ValueTask<int> MethodAsync(int a, int b); |
|
Request data and Response data are serealize by MessagePack-CSharp(LZ4MessagePackSerializer).
Please try to define the type according to MessagePack-CSharp rules.
NetStitch are Supported Analyzer and Codefix.
1.Get NetStitch.Analyzer from Nuget.
PM>Install-Package NetStitch.Analyzer
2.Implement INetStitchContract interface in Interface
3.Select NetStitchCodefix menu item
NetStitch is licensed under MIT. Refer to LICENSE for more information.
This Project is Inspired by LightNode.