Exemple #1
0
 /// <summary>
 /// Setup how and where the <see cref="TrackingStream"/> will capture its payload while being read.
 /// </summary>
 /// <param name="captureDescriptor">
 /// Describes how and where the stream is captured.
 /// </param>
 /// <param name="capturingStream">
 /// The <see cref="System.IO.Stream"/> to capture, or replicate, its payload to while being read.
 /// </param>
 internal virtual void SetupCapture(MessageBodyCaptureDescriptor captureDescriptor, System.IO.Stream capturingStream)
 {
     if (captureDescriptor == null)
     {
         throw new ArgumentNullException(nameof(captureDescriptor));
     }
     if (capturingStream == null)
     {
         throw new ArgumentNullException(nameof(capturingStream));
     }
     if (captureDescriptor.CaptureMode != MessageBodyCaptureMode.Claimed)
     {
         throw new InvalidOperationException(
                   $"{nameof(TrackingStream)}'s capture cannot be setup with a CaptureMode of {captureDescriptor.CaptureMode}; other CaptureMode than {MessageBodyCaptureMode.Claimed} cannot use a capturing stream.");
     }
     if (CaptureDescriptor != null)
     {
         throw new InvalidOperationException($"{nameof(TrackingStream)}'s capture has already been setup and cannot be overwritten.");
     }
     ThrowIfDisposed();
     ResetPositionAndStopMarking();
     CaptureDescriptor = captureDescriptor;
     InnerStream       = new ReplicatingReadStream(InnerStream, capturingStream);
 }