public void Setup() { _actualService = new MockService(); _marshalledOnServer = Marshal.Get(_actualService); _marshalledOnClient = Marshal.Get<IMockService>((Func<string, object[], object>) ((name, args) => _marshalledOnServer.Invoke(name, args))); }
private static void HandleRequest(HttpListener listener, IMarshalled marshalledService) { try { var context = listener.GetContext(); var data = new byte[context.Request.ContentLength64]; context.Request.InputStream.ReadTo(data); var callspec = Serialization.Build<MarshalledCall>(data); var result = marshalledService.Invoke(callspec.Name, callspec.Args); if (result != null) context.Response.Close(Serialization.Break(result), true); else context.Response.Close(); } catch (HttpListenerException ex) { if (ex.ErrorCode != WindowsError_OperationAborted) throw; // Terminate peacefully by request. } }