internal StreamTransferEventArgs(PendingStream stream, StreamTransferEventType eventType)
        {
            Require.NotNull(stream, "stream");

            Length = stream.Length;
            StreamName = stream.StreamName;
            ContentType = stream.ContentType;
            Disposition = stream.Disposition;
            StreamId = stream.AssociationId;
            EventType = eventType;
            StreamType = stream is PendingSendStream ? StreamType.Send : StreamType.Receive;

            switch (eventType)
            {
                case StreamTransferEventType.Start:
                    Transferred = 0;
                    break;

                case StreamTransferEventType.End:
                    Transferred = Length;
                    break;

                default:
                    if (!stream.IsDisposed)
                        Transferred = stream.Position;
                    break;
            }
        }
示例#2
0
        void IStreamTransferListener.RaiseStreamTransfer(PendingStream stream, StreamTransferEventType eventType)
        {
            Require.NotNull(stream, "stream");

            try
            {
                OnStreamTransfer(new StreamTransferEventArgs(stream, eventType));
            }
            catch (Exception ex)
            {
                Log.Warn("Exception while raising StreamTransfer event", ex);
            }
        }
 private void RaiseEvent(PendingStream pendingStream, StreamTransferEventType eventType)
 {
     if (_streamTransferListener != null)
         _streamTransferListener.RaiseStreamTransfer(pendingStream, eventType);
 }