Exemplo n.º 1
0
        /// <summary>
        /// Reads the error data in XML attributes.
        /// </summary>

        private static void ReadXmlAttributes(XmlReader reader, Error error)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (!reader.IsStartElement())
            {
                throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");
            }

            error.ApplicationName = reader.GetAttribute("application");
            error.HostName        = reader.GetAttribute("host");
            error.Type            = reader.GetAttribute("type");
            error.Message         = reader.GetAttribute("message");
            error.Source          = reader.GetAttribute("source");
            error.Detail          = reader.GetAttribute("detail");
            error.User            = reader.GetAttribute("user");
            string timeString = Mask.NullString(reader.GetAttribute("time"));

            error.Time = timeString.Length == 0 ? new DateTime() : XmlConvert.ToDateTime(timeString);
            string statusCodeString = Mask.NullString(reader.GetAttribute("statusCode"));

            error.StatusCode         = statusCodeString.Length == 0 ? 0 : XmlConvert.ToInt32(statusCodeString);
            error.WebHostHtmlMessage = reader.GetAttribute("webHostHtmlMessage");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the error data that belongs in XML attributes.
        /// </summary>

        private static void WriteXmlAttributes(Error error, XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            WriteXmlAttribute(writer, "application", error.ApplicationName);
            WriteXmlAttribute(writer, "host", error.HostName);
            WriteXmlAttribute(writer, "type", error.Type);
            WriteXmlAttribute(writer, "message", error.Message);
            WriteXmlAttribute(writer, "source", error.Source);
            WriteXmlAttribute(writer, "detail", error.Detail);
            WriteXmlAttribute(writer, "user", error.User);
            if (error.Time != DateTime.MinValue)
            {
                WriteXmlAttribute(writer, "time", XmlConvert.ToString(error.Time.ToUniversalTime(), @"yyyy-MM-dd\THH:mm:ss.fffffff\Z"));
            }
            if (error.StatusCode != 0)
            {
                WriteXmlAttribute(writer, "statusCode", XmlConvert.ToString(error.StatusCode));
            }
            WriteXmlAttribute(writer, "webHostHtmlMessage", error.WebHostHtmlMessage);
        }
Exemplo n.º 3
0
 private static void CheckCharacters(string value)
 {
     XmlConvert.VerifyCharData(value, ExceptionType.ArgumentException, ExceptionType.XmlException);
 }