/// <summary>
 /// Creates a <see cref="WSTrustChannel" /> using parameters that reflect the configuration of
 /// this factory.
 /// </summary>
 /// <param name="innerChannel">The channel created by the base class capable of sending and
 /// receiving messages.</param>
 /// <param name="trustVersion">The version of WS-Trust that should be used.</param>
 /// <param name="context">
 /// The <see cref="WSTrustSerializationContext" /> that should be used to serialize WS-Trust messages.
 /// </param>
 /// <param name="requestSerializer">
 /// The <see cref="WSTrustRequestSerializer" /> that should be used to serialize WS-Trust request messages.
 /// </param>
 /// <param name="responseSerializer">
 /// The <see cref="WSTrustResponseSerializer" /> that should be used to serialize WS-Trust response messages.
 /// </param>
 /// <returns></returns>
 protected virtual WSTrustChannel CreateTrustChannel(IWSTrustChannelContract innerChannel,
                                                     TrustVersion trustVersion,
                                                     WSTrustSerializationContext context,
                                                     WSTrustRequestSerializer requestSerializer,
                                                     WSTrustResponseSerializer responseSerializer)
 {
     return(new WSTrustChannel(this, innerChannel, trustVersion, context, requestSerializer, responseSerializer));
 }
        /// <summary>
        /// Initializes an instance of <see cref="WSTrustResponseBodyWriter"/>
        /// </summary>
        /// <param name="requestSecurityTokenResponse">The Response object that can write the body contents.</param>
        /// <param name="serializer">Serializer to use for serializing the RSTR.</param>
        /// <param name="context">The <see cref="WSTrustSerializationContext"/> of this request.</param>
        /// <exception cref="ArgumentNullException">serializer parameter is null.</exception>
        public WSTrustResponseBodyWriter(RSTR requestSecurityTokenResponse, WSTrustResponseSerializer serializer, WSTrustSerializationContext context)
            : base(true)
        {
            if (serializer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serializer");
            }

            if (requestSecurityTokenResponse == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestSecurityTokenResponse");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            _serializer = serializer;
            _rstr       = requestSecurityTokenResponse;
            _context    = context;
        }