namespace System.Reflection { /// /// DispatchProxy provides a mechanism for the instantiation of proxy objects and handling of /// their method dispatch. /// Original file: https://github.com/dotnet/runtime/blob/6072e4d3a7a2a1493f514cdf4be75a3d56580e84/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs /// public abstract class DispatchProxy { protected DispatchProxy() { } /// /// Whenever any method on the generated proxy type is called, this method /// will be invoked to dispatch control. /// /// The method the caller invoked /// The arguments the caller passed to the method /// The object to return to the caller, or null for void methods protected abstract object? Invoke(MethodInfo? targetMethod, object?[]? args); /// /// Creates an object instance that derives from class /// and implements interface . /// /// The interface the proxy should implement. /// The base class to use for the proxy class. /// An object instance that implements . /// is a class, /// or is sealed or does not have a parameterless constructor public static T Create() where TProxy : DispatchProxy { return (T)DispatchProxyGenerator.CreateProxyInstance(typeof(TProxy), typeof(T)); } } }