public T GetService <T>() where T : class { if (!typeof(T).IsInterface) { throw new Exception($"type {typeof(T)} must be interface"); } var result = httpClient.GetStringAsync($"http://{hostName}:{port}/ip/TCPRegister/ConnectoToService/{typeof(T).Name}").Result; var data = JObject.Parse(result).ToObject <Response>(); if (!data.Success) { throw new ServiceUnavailableException(); } var transporter = new TCPTransporter(hostName, data.Port, data.Password, loggerFactory.CreateLogger <TCPTransporter>()); var disposableInterface = DisposableWrapper(typeof(T)); T worker; if (disposableInterface == typeof(T)) { worker = RemoteWorker.Create(disposableInterface, transporter, 0) as T; } else { worker = RemoteWorker.Create(disposableInterface, transporter, 0, true) as T; } return(worker); }
private object CreateRemoteInvoker(long invokerId, Type invokerType) { return(RemoteWorker.Create(invokerType, transporter, invokerId)); }