forked from NetCoreStack/Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxyHelper.cs
More file actions
20 lines (19 loc) · 744 Bytes
/
Copy pathProxyHelper.cs
File metadata and controls
20 lines (19 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Microsoft.Extensions.DependencyInjection;
using NetCoreStack.Contracts;
using System;
using System.Reflection;
namespace NetCoreStack.Proxy.Internal
{
internal static class ProxyHelper
{
internal static TProxy CreateProxy<TProxy>(IServiceProvider container) where TProxy : IApiContract
{
dynamic proxy = DispatchProxyAsync.Create<TProxy, HttpDispatchProxy>();
var proxyContextFilter = container.GetService<IProxyContextFilter>();
var proxyContext = new ProxyContext(typeof(TProxy));
proxyContextFilter.Invoke(proxyContext);
proxy.Initialize(proxyContext, container.GetService<IProxyManager>());
return proxy;
}
}
}