https://github.com/channeladam/channeladam.dispatchproxies
A .NET library with disposable and retry-enabled dispatch proxies.
https://github.com/channeladam/channeladam.dispatchproxies
channeladam dispatch-proxy dotnet dotnet-standard proxy
Last synced: 3 months ago
JSON representation
A .NET library with disposable and retry-enabled dispatch proxies.
- Host: GitHub
- URL: https://github.com/channeladam/channeladam.dispatchproxies
- Owner: channeladam
- License: apache-2.0
- Created: 2017-08-02T15:22:38.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T01:23:26.000Z (over 3 years ago)
- Last Synced: 2025-07-06T08:42:55.274Z (about 1 year ago)
- Topics: channeladam, dispatch-proxy, dotnet, dotnet-standard, proxy
- Language: C#
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChannelAdam.DispatchProxies
A .NET Standard library with disposable and retry-enabled dispatch proxies.
Targets:
- .NET 5.0
- .NET Standard 2.1
- .NET Standard 2.0
- .NET Standard 1.0
## Usage
Invoke Handler:
```csharp
public class MyObjectInvokeHandler : IObjectInvokeHandler
{
public object? Invoke(object targetObject, MethodInfo targetMethod, object?[]? args)
{
Console.WriteLine($"Handling invocation of method {targetMethod.Name}");
// Add your dispatch proxy code here!
return targetMethod.Invoke(targetObject, args);
}
}
```
Creation of the dispatch proxy:
```csharp
ICalculator calculatorProxy = DispatchProxyFactory.CreateObjectDispatchProxy(
new Calculator(),
new MyObjectInvokeHandler());
// When you want the dispatch proxy to wrap around an IDisposable
ICalculator calculatorProxy = DispatchProxyFactory.CreateDisposableObjectDispatchProxy(
new Calculator(),
new MyObjectInvokeHandler());
// When you want the dispatch proxy to wrap around an IDisposable with a destructor
ICalculator calculatorProxy = DispatchProxyFactory.CreateDisposableObjectDispatchProxyWithDestructor(
new Calculator(),
new MyObjectInvokeHandler());
```
See the BehaviourSpecs for further example usage.