Beispiel #1
0
        /// <summary>
        /// Replaces this <paramref name="messagePart"/>'s original data stream by another <paramref name="stream"/>.
        /// </summary>
        /// <param name="messagePart">
        /// The part whose original data stream is replaced.
        /// </param>
        /// <param name="stream">
        /// The replacement stream.
        /// </param>
        /// <param name="tracker">
        /// Pipeline's resource tracker to which to report the newly created wrapping stream.
        /// </param>
        public static void SetDataStream(this IBaseMessagePart messagePart, Stream stream, IResourceTracker tracker)
        {
            if (messagePart == null)
            {
                throw new ArgumentNullException(nameof(messagePart));
            }
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (tracker == null)
            {
                throw new ArgumentNullException(nameof(tracker));
            }

            messagePart.Data = stream;
            tracker.AddResource(stream);
        }
        /// <summary>
        /// Replaces this <paramref name="messagePart"/>'s original data stream by another <paramref name="stream"/>.
        /// </summary>
        /// <param name="messagePart">
        /// The part whose original data stream is replaced.
        /// </param>
        /// <param name="stream">
        /// The replacement stream.
        /// </param>
        /// <param name="tracker">
        /// Pipeline's resource tracker to which to report the newly created wrapping stream.
        /// </param>
        public static void SetDataStream(this IBaseMessagePart messagePart, Stream stream, IResourceTracker tracker)
        {
            // TODO ?consider providing an overload when there is no IResourceTracker as this is necessary only for unmanaged objects/resources? not really necessary as one could use Data setter, but it'd be consistent/balanced API

            if (messagePart == null)
            {
                throw new ArgumentNullException("messagePart");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (tracker == null)
            {
                throw new ArgumentNullException("tracker");
            }

            messagePart.Data = stream;
            tracker.AddResource(stream);
        }