https://github.com/havendv/h.proxyfactory
Allows creating proxy objects that look exactly like the original objects.
https://github.com/havendv/h.proxyfactory
ipc net5 net6 netstandard pipes pub-sub pubsub request-response rpc
Last synced: 16 days ago
JSON representation
Allows creating proxy objects that look exactly like the original objects.
- Host: GitHub
- URL: https://github.com/havendv/h.proxyfactory
- Owner: HavenDV
- License: mit
- Created: 2020-11-25T06:16:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T18:37:58.000Z (over 3 years ago)
- Last Synced: 2025-04-12T12:55:55.203Z (22 days ago)
- Topics: ipc, net5, net6, netstandard, pipes, pub-sub, pubsub, request-response, rpc
- Language: C#
- Homepage:
- Size: 539 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [H.ProxyFactory](https://github.com/HavenDV/H.ProxyFactory/)
[](https://github.com/HavenDV/H.ProxyFactory/search?l=C%23&o=desc&s=&type=Code)
[](LICENSE.md)
[](https://github.com/dotnet/standard/blob/master/docs/versions/netstandard2.0.md)
[](https://github.com/HavenDV/H.ProxyFactory/actions?query=workflow%3A%22.NET%22)Allows you to interact with remote objects.
You will have access to an interface through which you will interact with the object created on the server.Features:
- Create proxy objects that look exactly like the original objects
- Proxy target can be located anywhere where there is access to pipes### Nuget
[](https://www.nuget.org/packages/H.ProxyFactory.Pipes/)
```
Install-Package H.ProxyFactory.Pipes
```### Usage
Shared code:
```cs
public interface IActionService
{
void SendText(string text);
void ShowTrayIcon();
void HideTrayIcon();event EventHandler TextReceived;
}public class ActionService { }
```Implementation in the server project:
```cs
public class ActionService : IActionService
{
private TrayIconService trayIconService = new();public void SendText(string text)
{
Console.WriteLine($"Text from client: {text}");TextReceived?.Invoke(this, "Hi from server");
}public void ShowTrayIcon()
{
trayIconService.ShowTrayIcon();
}public void HideTrayIcon()
{
trayIconService.HideTrayIcon();
}public event EventHandler? TextReceived;
}
```Server:
```cs
await using var server = new PipeProxyServer();await server.InitializeAsync("UniquePipeServerName");
```Client:
```cs
await using var factory = new PipeProxyFactory();await factory.InitializeAsync("UniquePipeServerName");
// You will have access to an interface through which you will interact with the object created on the server.
var service = await factory.CreateInstanceAsync();
instance.TextReceived += (_, text) =>
{
WriteLine($"{nameof(instance.TextReceived)}: {text}");
};
instance.ShowTrayIcon();
Instance.SendText("hello!");
```
### Contacts
* [mail](mailto:[email protected])