Skip to content

Commit 89b429e

Browse files
committed
Fixing UWP support for manually generated proxy classes
1 parent b18b153 commit 89b429e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: src/net45/WampSharp/WAMP2/V2/System.Reflection.DispatchProxy/WampCalleeClientProxyFactory.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if DISPATCH_PROXY
22

3+
using System;
34
using System.Reflection;
45
using WampSharp.V2.Client;
56

@@ -8,23 +9,32 @@ namespace WampSharp.V2.CalleeProxy
89
{
910
internal class WampCalleeClientProxyFactory : IWampCalleeProxyFactory
1011
{
12+
private readonly IWampRealmProxy mProxy;
1113
private readonly WampCalleeProxyInvocationHandler mHandler;
1214

1315
public WampCalleeClientProxyFactory(IWampRealmProxy proxy)
1416
{
17+
mProxy = proxy;
1518
mHandler = new ClientInvocationHandler(proxy);
1619
}
1720

1821
public virtual TProxy GetProxy<TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
1922
{
20-
TProxy result = DispatchProxy.Create<TProxy, CalleeProxy>();
23+
if (typeof(CalleeProxyBase).IsAssignableFrom(typeof(TProxy)))
24+
{
25+
return (TProxy) Activator.CreateInstance(typeof(TProxy), mProxy, interceptor);
26+
}
27+
else
28+
{
29+
TProxy result = DispatchProxy.Create<TProxy, CalleeProxy>();
2130

22-
CalleeProxy casted = result as CalleeProxy;
31+
CalleeProxy casted = result as CalleeProxy;
2332

24-
casted.Handler = mHandler;
25-
casted.CalleeProxyInterceptor = interceptor;
33+
casted.Handler = mHandler;
34+
casted.CalleeProxyInterceptor = interceptor;
2635

27-
return result;
36+
return result;
37+
}
2838
}
2939
}
3040
}

0 commit comments

Comments
 (0)