//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//-----------------------------------------------------------------------
namespace System.IdentityModel.Protocols.WSTrust
{
    using System.Xml;
    /// 
    /// Base class for support of versions of WS-Trust request messages.
    /// 
    public abstract class WSTrustResponseSerializer
    {
        /// 
        /// When overriden in the derived class deserializes the RSTR from the XmlReader to a RequestSecurityTokenResponse object.
        /// 
        /// XML reader over the RSTR
        /// Current Serialization context.
        /// RequestSecurityTokenResponse object if teh deserialization was successful
        public abstract RequestSecurityTokenResponse ReadXml(XmlReader reader, WSTrustSerializationContext context);
        /// 
        /// When overridden in the derived class reads a child element inside RSTR.
        /// 
        /// Reader pointing at an element to read inside the RSTR.
        /// The RequestSecurityTokenResponse element that is being populated from the reader.
        /// Current Serialization context.
        public abstract void ReadXmlElement(XmlReader reader, RequestSecurityTokenResponse requestSecurityTokenResponse, WSTrustSerializationContext context);
        /// 
        /// When overridden in the derived class writes out the supported elements on the response object. 
        /// 
        /// The response instance
        /// The writer to write to
        /// Current Serialization context.
        public abstract void WriteKnownResponseElement(RequestSecurityTokenResponse requestSecurityTokenResponse, XmlWriter writer, WSTrustSerializationContext context);
        /// 
        /// When overriden in the derived class serializes the given RequestSecurityTokenResponse into the XmlWriter
        /// 
        /// RequestSecurityTokenRespone object to be serializes
        /// XML writer to serialize into
        /// Current Serialization context.
        public abstract void WriteXml(RequestSecurityTokenResponse response, XmlWriter writer, WSTrustSerializationContext context);
        /// 
        /// When overridden in the derived class writes a specific RSTR parameter to the outgoing stream.
        /// 
        /// Writer to which the RSTR is serialized
        /// The Local name of the element to be written.
        /// The value of the element.
        /// The entire RSTR object that is being serialized.
        /// Current Serialization context.
        public abstract void WriteXmlElement(XmlWriter writer, string elementName, object elementValue, RequestSecurityTokenResponse requestSecurityTokenResponse, WSTrustSerializationContext context);
        /// 
        /// Creates an instance of the RequestSecurityTokenResponse object that this class can Serialize or Deserialize.
        /// 
        /// Instance of RequestSecurityTokenResponse object
        public virtual RequestSecurityTokenResponse CreateInstance()
        {
            return new RequestSecurityTokenResponse();
        }
        /// 
        /// Validates the RequestSecurityTokenResponse object that has been deserialized.
        /// 
        /// The RequestSecurityTokenResponse object to Validate.
        /// An Response for an IssueRequest does not contain the RequestedSecurityToken.
        public virtual void Validate(RequestSecurityTokenResponse requestSecurityTokenResponse)
        {
            if (requestSecurityTokenResponse == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rstr");
            }
        }
        /// 
        /// When implemented in the derived class checks if the given reader is positioned at a RequestSecurityTokenResponse element.
        /// 
        /// The reader to read from.
        /// 'True' if the reader is positioned at an RSTR element that this serializer can read.
        public abstract bool CanRead(XmlReader reader);
    }
}