Skip to content

Instantly share code, notes, and snippets.

@NikitaChizhov
Last active February 11, 2020 20:44
Show Gist options
  • Save NikitaChizhov/cb3a4a60c1b4b907c4457758c52efb67 to your computer and use it in GitHub Desktop.
Save NikitaChizhov/cb3a4a60c1b4b907c4457758c52efb67 to your computer and use it in GitHub Desktop.
internal class DispatchProxyEmptyDecorator<TDecorated> : DispatchProxy
{
private TDecorated _decorated;
protected override object Invoke(MethodInfo targetMethod, object[] args)
{
var result = targetMethod.Invoke(_decorated, args);
return result;
}
public static TDecorated Create(TDecorated decorated)
{
object proxy = Create<TDecorated, DispatchProxyLoggingDecorator<TDecorated>>();
((DispatchProxyLoggingDecorator<TDecorated>)proxy).SetParameters(decorated);
return (TDecorated)proxy;
}
private void SetParameters(TDecorated decorated)
{
_decorated = decorated ?? throw new ArgumentNullException(nameof(decorated));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment