示例#1
0
        /// <summary>
        /// Runs all <see cref="IMessageInterceptor"/> in the collection on the input, in order
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="headers">the message headers</param>
        /// <returns></returns>
        public MessageInterceptorsResult MessageToBytes(byte[] input, IReadOnlyDictionary <string, object> headers)
        {
            if (!_interceptors.Any())
            {
                return new MessageInterceptorsResult {
                           Output = input
                }
            }
            ;
            var output = new MessageInterceptorsResult();
            var bytes  = input;

            foreach (var interceptor in _interceptors)
            {
                var temp = interceptor.MessageToBytes(bytes, headers);

                if (temp.AddToGraph)
                {
                    output.Graph.Add(temp.BaseType);
                }
                bytes = temp.Output;
            }
            output.Output = bytes;
            return(output);
        }
示例#2
0
        /// <summary>
        /// Runs all <see cref="IMessageInterceptor"/> in the collection on the input, in order
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public MessageInterceptorsResult MessageToBytes(byte[] input)
        {
            if (Count == 0)
            {
                return new MessageInterceptorsResult {
                           Output = input
                }
            }
            ;
            var output = new MessageInterceptorsResult();
            var bytes  = input;

            foreach (var interceptor in this)
            {
                var temp = interceptor.MessageToBytes(bytes);

                if (temp.AddToGraph)
                {
                    output.Graph.Add(temp.BaseType);
                }
                bytes = temp.Output;
            }
            output.Output = bytes;
            return(output);
        }