private TcpClientTermination(SerializationInfo info, StreamingContext context)
 {
     localEndPoint  = (EndPoint)info.GetValue("localEndPoint", typeof(EndPoint));
     remoteEndPoint = (EndPoint)info.GetValue("remoteEndPoint", typeof(EndPoint));
     duration       = (TimeSpan)info.GetValue("duration", typeof(TimeSpan));
     reason         = (QbservableProtocolShutDownReason)info.GetValue("reason", typeof(QbservableProtocolShutDownReason));
     exceptions     = ((List <Exception>)info.GetValue("rawExceptions", typeof(List <Exception>)))
                      .Select(ExceptionDispatchInfo.Capture)
                      .ToList()
                      .AsReadOnly();
 }
 public TcpClientTermination(
     EndPoint localEndPoint,
     EndPoint remoteEndPoint,
     TimeSpan duration,
     QbservableProtocolShutDownReason reason,
     IEnumerable <ExceptionDispatchInfo> exceptions)
 {
     this.localEndPoint  = localEndPoint;
     this.remoteEndPoint = remoteEndPoint;
     this.duration       = duration;
     this.reason         = reason;
     this.exceptions     = (exceptions ?? Enumerable.Empty <ExceptionDispatchInfo>())
                           .Distinct(ExceptionDispatchInfoEqualityComparer.Instance)
                           .ToList()
                           .AsReadOnly();
 }
        protected void ShutDownWithoutResponse(QbservableProtocolShutDownReason reason)
        {
            ShutDownReason = reason;

            CancelAllCommunication();
        }
        protected async Task ShutDownAsync(QbservableProtocolShutDownReason reason)
        {
            ShutDownReason = reason;

            await ShutDownCoreAsync().ConfigureAwait(false);
        }
 private QbservableProtocolShutDownReason GetShutDownReason(QbservableMessage message, QbservableProtocolShutDownReason defaultReason)
 {
     if (message.Data.Length > 0)
     {
         return((QbservableProtocolShutDownReason)message.Data[0]);
     }
     else
     {
         return(defaultReason);
     }
 }