/// <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="Stream"/> to capture, or replicate, its payload to while being read. /// </param> internal virtual void SetupCapture(MessageBodyCaptureDescriptor captureDescriptor, Stream capturingStream) { if (captureDescriptor == null) { throw new ArgumentNullException("captureDescriptor"); } if (capturingStream == null) { throw new ArgumentNullException("capturingStream"); } if (captureDescriptor.CaptureMode != MessageBodyCaptureMode.Claimed) { throw new InvalidOperationException( string.Format( "{0}'s capture cannot be setup with a CaptureMode of {1}; other CaptureMode than {2} cannot use a capturing stream.", typeof(TrackingStream).Name, captureDescriptor.CaptureMode, MessageBodyCaptureMode.Claimed)); } if (CaptureDescriptor != null) { throw new InvalidOperationException( string.Format( "{0}'s capture has already been setup and cannot be overwritten.", typeof(TrackingStream).Name)); } ThrowIfDisposed(); ResetPositionAndStopMarking(); CaptureDescriptor = captureDescriptor; InnerStream = new ReplicatingReadStream(InnerStream, capturingStream); }
/// <summary> /// Creates a new instance of a <see cref="TrackingStream"/> and provides information about how and where a payload has /// already been tracked, typically when a claim check token is redeemed. /// </summary> /// <param name="stream"> /// The <see cref="System.IO.Stream"/> to endow with tracking and claim support. /// </param> /// <param name="captureDescriptor"> /// The <see cref="MessageBodyCaptureDescriptor"/> describing the previously captured-to-disk payload stream to reuse. /// </param> internal TrackingStream(System.IO.Stream stream, MessageBodyCaptureDescriptor captureDescriptor) : this(stream) { if (captureDescriptor == null) { throw new ArgumentNullException(nameof(captureDescriptor)); } if (captureDescriptor.CaptureMode != MessageBodyCaptureMode.Claimed) { throw new ArgumentException( $"A {nameof(TrackingStream)}, whose payload is being redeemed, cannot be instantiated with a CaptureDescriptor having a CaptureMode of {captureDescriptor.CaptureMode}; the only compliant CaptureMode is {MessageBodyCaptureMode.Claimed}.", nameof(captureDescriptor)); } CaptureDescriptor = captureDescriptor; }
/// <summary> /// Associates the <see cref="MessageBodyCaptureDescriptor"/> describing how and where the <see /// cref="IBaseMessage.BodyPart"/>'s <see cref="IBaseMessagePart.Data"/> of the <see cref="IBaseMessage"/> being /// processed is captured with its related BAM <c>MessagingStep</c> activity. /// </summary> /// <param name="captureDescriptor"> /// Descriptive information on how and where the <see cref="IBaseMessage.BodyPart"/>'s <see /// cref="IBaseMessagePart.Data"/> of the <see cref="IBaseMessage"/> being processed is captured. /// </param> private void TrackMessageBody(MessageBodyCaptureDescriptor captureDescriptor) { if (captureDescriptor == null) { throw new ArgumentNullException("captureDescriptor"); } AddCustomReference( captureDescriptor.CaptureMode.ToString(), MESSAGE_BODY_REFERENCE_NAME, // timestamp because it is mandatory to use a non-null reference data DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), captureDescriptor.Data); }
/// <summary> /// Creates a new instance of a <see cref="TrackingStream"/> and provides information about how and where a /// payload has already been tracked, typically when a claim check token is redeemed. /// </summary> /// <param name="stream"> /// The <see cref="Stream"/> to endow with tracking and claim support. /// </param> /// <param name="captureDescriptor"> /// The <see cref="MessageBodyCaptureDescriptor"/> describing the previously captured-to-disk payload stream to /// reuse. /// </param> internal TrackingStream(Stream stream, MessageBodyCaptureDescriptor captureDescriptor) : this(stream) { if (captureDescriptor == null) { throw new ArgumentNullException("captureDescriptor"); } if (captureDescriptor.CaptureMode != MessageBodyCaptureMode.Claimed) { throw new ArgumentException( string.Format( "A {0}, whose payload is being redeemed, cannot be instantiated with a CaptureDescriptor having a CaptureMode of {1}; the only compliant CaptureMode is {2}.", typeof(TrackingStream).Name, captureDescriptor.CaptureMode, MessageBodyCaptureMode.Claimed), "captureDescriptor"); } CaptureDescriptor = captureDescriptor; }
/// <summary> /// Provide information about how and where the <see cref="TrackingStream"/> payload has been captured. /// </summary> /// <param name="captureDescriptor"> /// Describes how and where the stream is captured. /// </param> internal virtual void SetupCapture(MessageBodyCaptureDescriptor captureDescriptor) { if (captureDescriptor == null) { throw new ArgumentNullException(nameof(captureDescriptor)); } if (captureDescriptor.CaptureMode != MessageBodyCaptureMode.Unclaimed) { throw new InvalidOperationException( $"{nameof(TrackingStream)}'s capture cannot be setup with a CaptureMode of {captureDescriptor.CaptureMode}; other CaptureMode than {MessageBodyCaptureMode.Unclaimed} requires 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; }
/// <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); }