Skip to content
forked from HavenDV/H.Ipc

C# Source Generator library for Inter-Process Communication

License

Notifications You must be signed in to change notification settings

bitwreckage/H.Ipc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

H.Ipc

This generator allows you to generate boilerplate code for H.Pipes based on the interface you specify. Generation example: HavenDV/H.ProxyFactory#7 (comment)

Nuget

NuGet

Install-Package H.Ipc

Usage

// Common interface
public interface IActionService
{
    void ShowTrayIcon();
    void HideTrayIcon();
    void SendText(string text);
}

// Server side implementation
[H.IpcGenerators.IpcServer]
public partial class ActionService : IActionService
{
    public void ShowTrayIcon()
    {
        MessageBox.Show(nameof(ShowTrayIcon));
    }

    public void HideTrayIcon()
    {
        MessageBox.Show(nameof(HideTrayIcon));
    }

    public void SendText(string text)
    {
        MessageBox.Show(text);
    }
}

// Client side implementation
[H.IpcGenerators.IpcClient]
public partial class ActionServiceClient : IActionService
{
}

// Server initialization
await using var server = new PipeServer<string>(ServerName);
var service = new ActionService();
service.Initialize(server);
await server.StartAsync();

// Client initialization
await using var client = new PipeClient<string>(ServerName);
var service = new ActionServiceClient();
service.Initialize(client);
await client.ConnectAsync();

// Client usage
client.ShowTrayIcon();

Notes

The generated code currently requires C# version 8 and above. You can enable this using the following code in your .csproj file:

<PropertyGroup>
  <LangVersion>preview</LangVersion> <!-- or just 8.0 -->
</PropertyGroup>

Contacts

About

C# Source Generator library for Inter-Process Communication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%