public RpcProxyBase <LightweightMethodDef> CreateProxy <TService>() where TService : class { var generator = new LightweightProxyGenerator(); var factory = generator.GenerateObjectProxyFactory <TService>(null, null); var proxy = (LightweightProxyBase)factory(RpcObjectId.Empty, new TcpRpcConnection(new RpcConnectionInfo(new Uri("lightweight.tcp://localhost"))), null); return(proxy); }
internal NamedPipeRpcConnection( RpcConnectionInfo connectionInfo, IRpcClientOptions?options, LightweightProxyGenerator proxyGenerator, LightweightOptions?lightweightOptions) : base(connectionInfo, options, proxyGenerator, lightweightOptions) { }
private protected LightweightRpcConnection( RpcConnectionInfo connectionInfo, IRpcClientOptions?options, LightweightProxyGenerator proxyGenerator, LightweightOptions?lightweightOptions) : base(connectionInfo, options, proxyGenerator) { this.KeepSizeLimitedConnectionAlive = lightweightOptions?.KeepSizeLimitedConnectionAlive ?? true; this.AllowReconnect = lightweightOptions?.AllowReconnect ?? false; }
public void SingletonServiceProxy_ShouldUseRpcRequest() { var generator = new LightweightProxyGenerator(); var factory = generator.GenerateObjectProxyFactory <ISingletonService>(null, null); var proxy = (LightweightProxyBase)factory(RpcObjectId.Empty, new TcpRpcConnection(new RpcConnectionInfo(new Uri("lightweight.tcp://localhost"))), null); var addMethod = proxy.proxyMethods.Single(m => m.OperationName == "SciTech.Rpc.Tests.SingletonService.Add"); Assert.AreEqual(typeof(RpcRequest <int, int>), addMethod.RequestType); var subMethod = proxy.proxyMethods.Single(m => m.OperationName == "SciTech.Rpc.Tests.SingletonService.Sub"); Assert.AreEqual(typeof(RpcRequest <int, int>), subMethod.RequestType); var getStringsMethod = proxy.proxyMethods.Single(m => m.OperationName == "SciTech.Rpc.Tests.SingletonService.GetStrings"); Assert.AreEqual(typeof(RpcRequest <int>), getStringsMethod.RequestType); }
internal TcpRpcConnection( RpcConnectionInfo connectionInfo, AuthenticationClientOptions?authenticationOptions, IRpcClientOptions?options, LightweightProxyGenerator proxyGenerator, LightweightOptions?lightweightOptions) : base(connectionInfo, options, proxyGenerator, lightweightOptions) { var scheme = this.ConnectionInfo.HostUrl?.Scheme; switch (scheme) { case WellKnownRpcSchemes.LightweightTcp: break; default: throw new ArgumentException("Invalid connectionInfo scheme.", nameof(connectionInfo)); } if (authenticationOptions != null) { if (authenticationOptions is SslClientOptions || authenticationOptions is NegotiateClientOptions || authenticationOptions is AnonymousAuthenticationClientOptions) { this.authenticationOptions = authenticationOptions; } else { throw new ArgumentException("Authentication options not supported.", nameof(authenticationOptions)); } } else { this.authenticationOptions = AnonymousAuthenticationClientOptions.Instance; } }
public void CallbackWithReturn_Should_Throw() { var proxyGenerator = new LightweightProxyGenerator(); Assert.Throws <RpcDefinitionException>(() => proxyGenerator.GenerateObjectProxyFactory <ICallbackWithReturnService>(null, null)); }
public void UnsupportedCallback2_Should_Throw() { var proxyGenerator = new LightweightProxyGenerator(); Assert.Throws <RpcDefinitionException>(() => proxyGenerator.GenerateObjectProxyFactory <IUnsupportCallbackService2>(null, null)); }