/// <summary>
        /// Deserialize the object from xml.
        /// </summary>
        /// <param name="reader">The xml reader for reading the
        /// serialized xml.</param>
        public virtual void ReadXml(XmlReader reader)
        {
            XmlDocument doc = SerializationUtilities.LoadXml(reader.ReadOuterXml());

            XmlNameTable xmlnt = doc.NameTable;
            XmlElement   root  = doc.CreateElement(XmlElementName, XmlNamespace);

            XmlNodeList xmlNodes = doc.DocumentElement.SelectNodes("*");

            foreach (XmlNode node in xmlNodes)
            {
                root.AppendChild(node);
            }
            doc.RemoveAll();
            doc.AppendChild(root);

            string contents = doc.OuterXml;

            foreach (string key in placeHolders.Keys)
            {
                if (placeHolders[key] != null)
                {
                    contents = contents.Replace(placeHolders[key], key);
                }
            }
            Stub = SerializationUtilities.DeserializeFromXmlText(contents, Stub.GetType());
        }
        /// <summary>
        /// Clone this object.
        /// </summary>
        /// <returns>
        /// A cloned object.
        /// </returns>
        public object Clone()
        {
            SoapHeaderBase header = (SoapHeaderBase)Activator.CreateInstance(this.GetType());

            header.Stub = SerializationUtilities.DeserializeFromXmlText(
                SerializationUtilities.SerializeAsXmlText(this.Stub), this.Stub.GetType());
            return(header);
        }
Beispiel #3
0
 /// <summary>
 /// Protected constructor. Used by serialization frameworks while
 /// deserializing an exception object.
 /// </summary>
 /// <param name="info">Info about the serialization context.</param>
 /// <param name="context">A streaming context that represents the
 /// serialization stream.</param>
 protected DfpApiException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     apiException = SerializationUtilities.DeserializeFromXmlText(
         GetValue <string>(info, "apiException"),
         GetValue <Type>(info, "apiExceptionType"));
 }
Beispiel #4
0
        /// <summary>
        /// Parses the XML response from the server into a type object.
        /// </summary>
        /// <typeparam name="T">The type of the object.</typeparam>
        /// <param name="contents">The XML contents.</param>
        /// <returns>The parsed object</returns>
        protected T ParseResponse <T>(string contents)
        {
            XmlDocument xDoc = XmlUtilities.CreateDocument(contents);

            string wrappedXml = string.Format(@"
          <?xml version='1.0' encoding='UTF-8'?>
          <root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
            {0}
          </root>", xDoc.DocumentElement.OuterXml).Trim();

            return((T)SerializationUtilities.DeserializeFromXmlText(wrappedXml, typeof(T)));
        }
Beispiel #5
0
        /// <summary>
        /// Protected constructor. Used by serialization frameworks while
        /// deserializing an exception object.
        /// </summary>
        /// <param name="info">Info about the serialization context.</param>
        /// <param name="context">A streaming context that represents the
        /// serialization stream.</param>
        protected AdsOAuthException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            Error = (TokenErrorResponse)SerializationUtilities.DeserializeFromXmlText(
                GetValue <string>(info, "error"), typeof(TokenErrorResponse));

            HttpStatusCode temp;

            if (Enum.TryParse(GetValue <string>(info, "statusCode"), out temp))
            {
                this.StatusCode = temp;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Parses the response from Google Cloud Storage servers.
        /// </summary>
        /// <param name="contents">The response body.</param>
        /// <returns>A BatchJobMutateResponse object, generated by parsing the
        /// response from the server.</returns>
        private BatchJobMutateResponse ParseResponse(string contents)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(contents);

            string wrappedXml = string.Format(@"
          <?xml version='1.0' encoding='UTF-8'?>
          <root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
            {0}
          </root>", xDoc.DocumentElement.OuterXml).Trim();

            BatchJobMutateResponseEnvelope mutateResponseEnvelope =
                (BatchJobMutateResponseEnvelope)SerializationUtilities.DeserializeFromXmlText(
                    wrappedXml, typeof(BatchJobMutateResponseEnvelope));

            return(mutateResponseEnvelope.mutateResponse);
        }