Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/havendv/h.ipc
C# Source Generator library for Inter-Process Communication
https://github.com/havendv/h.ipc
csharp dotnet ipc net5 net6 pipes source-generator
Last synced: 19 days ago
JSON representation
C# Source Generator library for Inter-Process Communication
- Host: GitHub
- URL: https://github.com/havendv/h.ipc
- Owner: HavenDV
- License: mit
- Created: 2021-12-03T02:28:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T00:49:28.000Z (about 2 months ago)
- Last Synced: 2024-10-06T09:23:03.218Z (about 1 month ago)
- Topics: csharp, dotnet, ipc, net5, net6, pipes, source-generator
- Language: C#
- Homepage:
- Size: 236 KB
- Stars: 26
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# H.Ipc
This generator allows you to generate boilerplate code for [H.Pipes](https://github.com/HavenDV/H.Pipes) based on the interface you specify.
Generation example: https://github.com/HavenDV/H.ProxyFactory/issues/7#issuecomment-1072287342### Nuget
[![NuGet](https://img.shields.io/nuget/dt/H.Ipc.svg?style=flat-square&label=H.Ipc)](https://www.nuget.org/packages/H.Ipc/)
```
Install-Package H.Ipc
```### Usage
```cs
// Common interface
public interface IActionService
{
Task ShowTrayIcon();
Task HideTrayIcon();
Task SendText(string text);
Task GetAnswer(string question);
}// Server side implementation
[H.IpcGenerators.IpcServer]
public partial class ActionService : IActionService
{
public Task ShowTrayIcon()
{
MessageBox.Show(nameof(ShowTrayIcon));
return Task.CompletedTask;
}public Task HideTrayIcon()
{
MessageBox.Show(nameof(HideTrayIcon));
return Task.CompletedTask;
}public Task SendText(string text)
{
MessageBox.Show(text);
return Task.CompletedTask;
}
public async Task GetAnswer(string question)
{
return await Simulator.CalculateAnswer(question);
}
}// Client side implementation
[H.IpcGenerators.IpcClient]
public partial class ActionServiceClient : IActionService
{
}// Server initialization
await using var server = new PipeServer(ServerName);
var service = new ActionService();
service.Initialize(server);
await server.StartAsync();// Client initialization
await using var client = new PipeClient(ServerName);
var service = new ActionServiceClient();
service.Initialize(client);
await client.ConnectAsync();// Client usage
await client.ShowTrayIcon();
await client.SendText("Hello world!");
var result = await client.GetAnswer("What's the answer to the ultimate question of life, the universe, and everything?");
```### Notes
The generated code currently requires C# version 8 and above. You can enable this using the following code in your .csproj file:
```xmlpreview
```
### Contacts
* [mail](mailto:[email protected])