System.Reflection.DispatchProxy
4.8.0
Prefix Reserved
dotnet add package System.Reflection.DispatchProxy --version 4.8.0
NuGet\Install-Package System.Reflection.DispatchProxy -Version 4.8.0
<PackageReference Include="System.Reflection.DispatchProxy" Version="4.8.0" />
paket add System.Reflection.DispatchProxy --version 4.8.0
#r "nuget: System.Reflection.DispatchProxy, 4.8.0"
// Install System.Reflection.DispatchProxy as a Cake Addin #addin nuget:?package=System.Reflection.DispatchProxy&version=4.8.0 // Install System.Reflection.DispatchProxy as a Cake Tool #tool nuget:?package=System.Reflection.DispatchProxy&version=4.8.0
About
Provides a DispatchProxy
class to dynamically create proxy instances that implement a specified interface.
Key Features
Method invocations on a generated proxy instance are dispatched to a Invoke()
method. Having a single invoke method allows centralized handling for scenarios such as logging, error handling and caching.
How to Use
Create the proxy class that derives from DispatchProxy
, override Invoke()
and call one of the static DispatchProxy.Create()
methods to generate the proxy type.
The example below intercepts calls to the ICallMe
interface and logs them.
class Program
{
static void Main(string[] args)
{
ICallMe proxy = LoggingDispatchProxy.Create<ICallMe>(new MyClass());
proxy.CallMe("Hello!");
}
}
public interface ICallMe
{
void CallMe(string name);
}
public class MyClass : ICallMe
{
public void CallMe(string message)
{
Console.WriteLine($"Inside the called method with input '{message}'");
}
}
public class LoggingDispatchProxy : DispatchProxy
{
private ICallMe _target;
protected override object Invoke(MethodInfo targetMethod, object[] args)
{
Console.WriteLine($"Calling method: '{targetMethod.Name}' with arguments: '{string.Join(", ", args)}'");
object result = targetMethod.Invoke(_target, args);
Console.WriteLine($"Called method: '{targetMethod.Name}'.");
return result;
}
public static T Create<T>(T target) where T : class
{
LoggingDispatchProxy proxy = DispatchProxy.Create<T, LoggingDispatchProxy>() as LoggingDispatchProxy;
proxy._target = (ICallMe)target;
return proxy as T;
}
}
Main Types
The main types provided by this library are:
- System.Reflection.DispatchProxy
Additional Documentation
- API reference can be found in: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.dispatchproxy
License
System.Reflection.DispatchProxy is released as open source under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- System.Reflection.Emit (>= 4.7.0)
-
.NETStandard 2.1
- No dependencies.
NuGet packages (149)
Showing the top 5 NuGet packages that depend on System.Reflection.DispatchProxy:
Package | Downloads |
---|---|
System.Private.ServiceModel
Package Description |
|
CoreWCF.Primitives
CoreWCF is a port of the service side of Windows Communication Foundation (WCF) to .NET Core. The goal of this project is to enable existing WCF services to move to .NET Core. |
|
Microsoft.NETCore
Provides a set of packages that can be used when building portable libraries on .NETCore based platforms. \r\n TFS ID: 1599443, GitHub SHA: https://github.com/dotnet/corefx/tree/eede273a4dfabcea608621f5e1bbf8ad00584cfb |
|
Lykke.HttpClientGenerator
This package helps to generate client proxy for an api using the Refit library. It adds cache and retries using Polly to the generated proxies. User logic can also be added as wrappers to the requests or to the method calls. |
|
Z.EntityFramework.Classic
Entity Framework Classic is an EF6 fork with performance enhancement, new features, and .NET Core support. This package is FREE (Community Version) Some features are Prime (Enterprise Version) Prime features can be disabled with "EntityFrameworkManager.IsCommunity = true;" |
GitHub repositories (11)
Showing the top 5 popular GitHub repositories that depend on System.Reflection.DispatchProxy:
Repository | Stars |
---|---|
dotnet/wcf
This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
|
|
CoreWCF/CoreWCF
Main repository for the Core WCF project
|
|
malware-dev/MDK-SE
Malware's Development Kit for SE
|
|
RRQM/TouchSocket
TouchSocket is an integrated .NET networking framework that includes modules for socket, TCP, UDP, SSL, named pipes, HTTP, WebSocket, RPC, and more. It offers a one-stop solution for TCP packet issues and enables quick implementation of custom data message parsing using protocol templates.
|
|
open-telemetry/opentelemetry-dotnet-contrib
This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
|
Version | Downloads | Last updated |
---|---|---|
4.8.0 | 5,830 | 11/12/2024 |
4.7.1 | 121,102,366 | 5/12/2020 |
4.7.0 | 1,221,219 | 12/3/2019 |
4.7.0-preview3.19551.4 | 683 | 11/13/2019 |
4.7.0-preview2.19523.17 | 680 | 11/1/2019 |
4.7.0-preview1.19504.10 | 682 | 10/15/2019 |
4.6.0 | 759,715 | 9/23/2019 |
4.6.0-rc1.19456.4 | 719 | 9/16/2019 |
4.6.0-preview9.19421.4 | 810 | 9/4/2019 |
4.6.0-preview9.19416.11 | 650 | 9/4/2019 |
4.6.0-preview8.19405.3 | 817 | 8/13/2019 |
4.6.0-preview7.19362.9 | 730 | 7/23/2019 |
4.6.0-preview6.19303.8 | 2,641 | 6/12/2019 |
4.6.0-preview6.19264.9 | 697 | 9/4/2019 |
4.6.0-preview5.19224.8 | 959 | 5/6/2019 |
4.6.0-preview4.19212.13 | 767 | 4/18/2019 |
4.6.0-preview3.19128.7 | 801 | 3/6/2019 |
4.6.0-preview.19073.11 | 875 | 1/29/2019 |
4.6.0-preview.18571.3 | 933 | 12/3/2018 |
4.5.1 | 4,447,900 | 6/18/2018 |
4.5.0 | 147,704,566 | 5/29/2018 |
4.5.0-rc1 | 4,247,249 | 5/6/2018 |
4.5.0-preview2-26406-04 | 228,962 | 4/10/2018 |
4.5.0-preview1-26216-02 | 44,222 | 2/26/2018 |
4.4.0 | 53,067,208 | 8/11/2017 |
4.4.0-preview2-25405-01 | 17,706 | 6/27/2017 |
4.4.0-preview1-25305-02 | 98,030 | 5/9/2017 |
4.3.0 | 39,181,879 | 11/15/2016 |
4.3.0-preview1-24530-04 | 52,201 | 10/24/2016 |
4.0.1 | 90,033,712 | 6/27/2016 |
4.0.1-rc2-24027 | 2,102,586 | 5/16/2016 |
4.0.1-beta-23516 | 22,540 | 11/18/2015 |
4.0.1-beta-23409 | 4,609 | 10/15/2015 |
4.0.1-beta-23225 | 136,908 | 9/2/2015 |
4.0.0 | 1,516,063 | 7/29/2015 |
4.0.0-beta-23109 | 3,682 | 7/27/2015 |
4.0.0-beta-23019 | 3,782 | 6/30/2015 |
4.0.0-beta-22816 | 3,779 | 4/24/2015 |