示例#1
0
 /// <summary>
 /// Create a named pipes client.
 /// </summary>
 /// <param name="npAddress"></param>
 /// <param name="serializer">Inject your own serializer for complex objects and avoid using the Newtonsoft JSON DefaultSerializer.</param>
 public NpClient(NpEndPoint npAddress, ISerializer serializer = null)
 {
     if (null == serializer)
     {
         serializer = new DefaultSerializer();
     }
     _proxy = NpProxy.CreateProxy <TInterface>(npAddress, serializer);
 }
示例#2
0
 /// <summary>
 /// Creates a connection to the concrete object handling method calls on the pipeName server side
 /// </summary>
 /// <param name="serviceType"></param>
 /// <param name="npEndPoint"></param>
 public NpChannel(Type serviceType, NpEndPoint npEndPoint)
 {
     _serviceType = serviceType;
     _clientStream = new NamedPipeClientStream(npEndPoint.ServerName, npEndPoint.PipeName, PipeDirection.InOut);
     _clientStream.Connect(npEndPoint.ConnectTimeOutMs);
     _stream = new BufferedStream(_clientStream);
     _binReader = new BinaryReader(_clientStream);
     _binWriter = new BinaryWriter(_clientStream);
     SyncInterface(_serviceType);
 }
示例#3
0
 /// <summary>
 /// Creates a connection to the concrete object handling method calls on the pipeName server side
 /// </summary>
 /// <param name="serviceType"></param>
 /// <param name="npEndPoint"></param>
 public NpChannel(Type serviceType, NpEndPoint npEndPoint)
 {
     _serviceType  = serviceType;
     _clientStream = new NamedPipeClientStream(npEndPoint.ServerName, npEndPoint.PipeName, PipeDirection.InOut);
     _clientStream.Connect(npEndPoint.ConnectTimeOutMs);
     _stream    = new BufferedStream(_clientStream);
     _binReader = new BinaryReader(_clientStream);
     _binWriter = new BinaryWriter(_clientStream);
     try
     {
         SyncInterface(_serviceType);
     }
     catch (Exception)
     {
         this.Dispose(true);
         throw;
     }
 }
示例#4
0
 public NpClient(NpEndPoint npAddress)
 {
     _proxy = NpProxy.CreateProxy <TInterface>(npAddress);
 }