Exemple #1
0
        internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
        {
            if (m_headers.Count == 0)
            {
                return; // Don't write an empty element.
            }
            adaptor.WriteStartElement(elementName);

            for (int index = 0; index < m_headers.Count; ++index)
            {
                adaptor.WriteStartElement(Constants.Xml.HttpDetail.Headers.HeaderElement);
                adaptor.WriteAttribute(Constants.Xml.HttpDetail.Headers.NameAttribute, m_headers.GetKey(index));

                string[] values = m_headers.GetValues(index);
                if (values == null)
                {
                    adaptor.WriteXsiNilAttribute(true);
                }
                else
                {
                    foreach (string value in values)
                    {
                        adaptor.WriteElement(Constants.Xml.HttpDetail.Headers.ValueElement, value);
                    }
                }

                adaptor.WriteEndElement();
            }

            adaptor.WriteEndElement();
        }
Exemple #2
0
        private static void WriteDictionaryToXml(XmlWriteAdaptor writer, IDictionary dictionary, string elementName)
        {
            if (dictionary.Count > 0)
            {
                writer.WriteStartElement(elementName);

                IDictionaryEnumerator enumerator = dictionary.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string childElementName = XmlConvert.EncodeName((string)enumerator.Key);

                    if (enumerator.Value == null)
                    {
                        writer.WriteStartElement(childElementName);
                        writer.WriteAttribute("null", "true");
                        writer.WriteEndElement();
                    }
                    else if (enumerator.Value is IDictionary)
                    {
                        WriteDictionaryToXml(writer, (IDictionary)enumerator.Value, childElementName);
                    }
                    else
                    {
                        Debug.Assert(enumerator.Value is string, "enumerator.Value is string");
                        writer.WriteElement(childElementName, (string)enumerator.Value);
                    }
                }

                writer.WriteEndElement();
            }
        }
Exemple #3
0
        protected override void WriteContents(XmlWriteAdaptor adaptor)
        {
            adaptor.WriteStartElement(Constants.Xml.Exception.PropertiesElement);

            // Write out all properties.

            foreach (PropertyInfo propertyInfo in PropertyInfos)
            {
                // Write an element for each property, indicating whether it is null or not.

                adaptor.WriteStartElement(propertyInfo.Name);
                object value = m_properties[propertyInfo.Name];
                if (value == null)
                {
                    adaptor.WriteAttribute(Constants.Xsi.Prefix, Constants.Xsi.NilAttribute, Constants.Xsi.Namespace, XmlConvert.ToString(true));
                }
                else
                {
                    adaptor.WriteElementValue(TypeXmlConvert.ToString(m_properties[propertyInfo.Name], propertyInfo.Type));
                }
                adaptor.WriteEndElement();
            }

            adaptor.WriteEndElement();
        }
Exemple #4
0
 private void WriteDetails(XmlWriteAdaptor adaptor)
 {
     adaptor.WriteStartElement(Constants.Xml.Exception.DetailsElement);
     foreach (IEventDetail detail in m_details)
     {
         adaptor.WriteStartElement(detail.Name);
         ((IXmlSerializable)detail).WriteXml(adaptor.XmlWriter);
         adaptor.WriteEndElement();
     }
     adaptor.WriteEndElement();
 }
Exemple #5
0
 internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
 {
     adaptor.WriteStartElement(elementName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.Content.EncodingNameElement, _encodingName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.Content.LengthElement, XmlConvert.ToString(_length));
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.Content.TypeElement, _type);
     adaptor.WriteEndElement();
 }
Exemple #6
0
        public void WriteOuterXml(XmlWriter writer)
        {
            XmlWriteAdaptor adaptor = new XmlWriteAdaptor(writer, Constants.Xml.Namespace);

            adaptor.WriteStartElement(Constants.Xml.NetDetail.Name);
            WriteXml(adaptor);
            adaptor.WriteEndElement();
        }
Exemple #7
0
        private void WriteXml(XmlWriteAdaptor adaptor)
        {
            // Source.

            adaptor.WriteStartElement(Constants.Xml.SourceElement);
            adaptor.WriteName(_source);
            adaptor.WriteEndElement();

            // Event.

            adaptor.WriteStartElement(Constants.Xml.EventElement);
            adaptor.WriteName(_event);
            adaptor.WriteEndElement();

            // Type, Method, Message, Time, Sequence.

            adaptor.WriteElement(Constants.Xml.TypeElement, _type);
            adaptor.WriteElement(Constants.Xml.MethodElement, _method);
            adaptor.WriteElement(Constants.Xml.MessageElement, _message);

            // The message time is in UTC, but System.Xml.XmlConvert assumes it's local time and writes
            // the local timezone. Use LinkMe.Framework.Type.DateTime to avoid this.

            DateTime time = DateTime.FromSystemDateTime(_time, TimeZone.UTC);

            adaptor.WriteElement(Constants.Xml.TimeElement, TypeXmlConvert.ToString(time));

            if (_sequence != 0)
            {
                adaptor.WriteElement(Constants.Xml.SequenceElement, TypeXmlConvert.ToString(_sequence));
            }

            // Exception.

            if (_exception != null)
            {
                adaptor.WriteStartElement(Constants.Xml.ExceptionElement);
                _exception.WriteXml(adaptor.XmlWriter);
                adaptor.WriteEndElement();
            }

            // Details and Parameters.

            WriteDetails(adaptor);
            WriteParameters(adaptor);
        }
Exemple #8
0
 internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
 {
     adaptor.WriteStartElement(elementName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.User.HostNameElement, _hostName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.User.HostAddressElement, _hostAddress);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Request.User.AgentElement, _agent);
     adaptor.WriteEndElement();
 }
Exemple #9
0
        public void WriteOuterXml(XmlWriter writer)
        {
            var adaptor = new XmlWriteAdaptor(writer);

            adaptor.WriteStartElement(OuterElement);
            WriteXml(adaptor);
            writer.WriteEndElement();             // </exception>
        }
Exemple #10
0
		public void WriteOuterXml(XmlWriter writer)
		{
			var adaptor = new XmlWriteAdaptor(writer, Constants.Xml.Namespace);
			adaptor.WriteStartElement(Constants.Xml.EventDetails.RootElement);
			adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace);
			adaptor.WriteNamespace(Constants.Xsi.Prefix, Constants.Xsi.Namespace);
			WriteXml(adaptor);
			adaptor.WriteEndElement();
		}
Exemple #11
0
        private void WriteDetails(XmlWriteAdaptor adaptor)
        {
            // Iterate.

            if (_details != null)
            {
                adaptor.WriteStartElement(Constants.Xml.DetailsElement);

                foreach (IEventDetail detail in _details)
                {
                    adaptor.WriteStartElement(detail.Name);
                    ((IXmlSerializable)detail).WriteXml(adaptor.XmlWriter);
                    adaptor.WriteEndElement();
                }

                adaptor.WriteEndElement();
            }
        }
Exemple #12
0
        public void WriteOuterXml(XmlWriter xmlWriter)
        {
            XmlWriteAdaptor adaptor = new XmlWriteAdaptor(xmlWriter, GetXmlNamespace());

            adaptor.WriteStartElement(Constants.Xml.Exception.ExceptionElement);
            adaptor.WriteNamespace(GetXmlNamespace());
            WriteNamespaces(adaptor);
            adaptor.WriteAttribute(Constants.Xsi.TypeAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, GetType().Name);
            WriteXml(adaptor);
            adaptor.WriteEndElement();
        }
Exemple #13
0
        internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
        {
            if (_cookies.Count == 0)
            {
                return; // Don't write an empty element.
            }
            adaptor.WriteStartElement(elementName);

            for (var index = 0; index < _cookies.Count; ++index)
            {
                _cookies[index].WriteXml(adaptor, Constants.Xml.HttpDetail.Cookies.CookieElement);
            }

            adaptor.WriteEndElement();
        }
Exemple #14
0
 internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
 {
     adaptor.WriteStartElement(elementName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.HttpMethodElement, _httpMethod);
     adaptor.WriteElement(Constants.Xml.HttpDetail.UrlElement, _url);
     adaptor.WriteElement(Constants.Xml.HttpDetail.RawUrlElement, _rawUrl);
     adaptor.WriteElement(Constants.Xml.HttpDetail.UrlReferrerElement, _urlReferrer);
     adaptor.WriteElement(Constants.Xml.HttpDetail.IsAuthenticatedElement, XmlConvert.ToString(_isAuthenticated));
     adaptor.WriteElement(Constants.Xml.HttpDetail.IsLocalElement, XmlConvert.ToString(_isLocal));
     adaptor.WriteElement(Constants.Xml.HttpDetail.IsSecureConnectionElement, XmlConvert.ToString(_isSecureConnection));
     _headers.WriteXml(adaptor, Constants.Xml.HttpDetail.Headers.Name);
     _cookies.WriteXml(adaptor, Constants.Xml.HttpDetail.Cookies.Name);
     _form.WriteXml(adaptor, Constants.Xml.HttpDetail.Form.Name);
     _content.WriteXml(adaptor, Constants.Xml.HttpDetail.Request.Content.Name);
     _user.WriteXml(adaptor, Constants.Xml.HttpDetail.Request.User.Name);
     adaptor.WriteEndElement();
 }
Exemple #15
0
        private void WriteParameters(XmlWriteAdaptor adaptor)
        {
            // Only write something if there is something to write.

            if (_parameters != null)
            {
                adaptor.WriteStartElement(Constants.Xml.ParametersElement);

                // Iterate.

                foreach (EventParameter parameter in _parameters)
                {
                    parameter.WriteXml(adaptor);
                }

                adaptor.WriteEndElement();
            }
        }
Exemple #16
0
        public void WriteOuterXml(XmlWriter xmlWriter)
        {
            XmlWriteAdaptor adaptor = new XmlWriteAdaptor(xmlWriter, Constants.Xml.Namespace);

            adaptor.WriteStartElement(Constants.Xml.EventMessagesElement);

            // Add the XSI namespace.

            adaptor.WriteNamespace(Constants.Xsi.Prefix, Constants.Xsi.Namespace);
            adaptor.WriteNamespace(Constants.Xml.UtilityPrefix, Constants.Xml.UtilityNamespace);
            adaptor.WriteNamespace(Constants.Xml.TypePrefix, Constants.Xml.TypeNamespace);

            // Write the messages.

            WriteXml(adaptor);

            adaptor.WriteEndElement();
        }
Exemple #17
0
        private void WriteXml(XmlWriteAdaptor writer)
        {
            Debug.Assert(writer.XmlWriter.WriteState == WriteState.Element, "Invalid WriteState: " + writer.XmlWriter.WriteState);

            writer.WriteClass(Type);

            // XML element names should normally being with a lowercase letter, but we want to preserve the
            // case of all the property names.

            if (HelpLink != null)
            {
                writer.WriteElement("HelpLink", HelpLink);
            }
            if (Message != null)
            {
                writer.WriteElement("Message", Message);
            }
            if (Source != null)
            {
                writer.WriteElement("Source", Source);
            }
            if (StackTrace != null)
            {
                writer.WriteElement("StackTrace", StackTrace);
            }
            if (TargetSite != null)
            {
                writer.WriteElement("TargetSite", TargetSite);
            }
            writer.WriteElement("HResult", HResult);

            // Additional properties (defined on derived exception classes)

            WriteDictionaryToXml(writer, _properties, "additionalProperties");

            // Inner exception

            if (InnerException != null)
            {
                writer.WriteStartElement("innerException");
                InnerException.WriteXml(writer);
                writer.WriteEndElement();                 // </innerException>
            }
        }
Exemple #18
0
		private void WriteXml(XmlWriteAdaptor adaptor)
		{
			foreach (IEventDetail eventDetail in _details)
			{
				var serializable = eventDetail as IXmlSerializable;
				if (serializable != null)
				{
					adaptor.WriteStartElement(Constants.Xml.EventDetails.EventDetailElement);
					adaptor.WriteAttribute(Constants.Xml.ClassAttribute,
						eventDetail.GetType().AssemblyQualifiedName);
					serializable.WriteOuterXml(adaptor.XmlWriter);
					adaptor.WriteEndElement();
				}
				else
				{
					Debug.Fail("Event detail type '" + eventDetail.GetType().FullName + "' is not IXmlSerializable.");
				}
			}
		}
Exemple #19
0
        public void WriteOuterXml(XmlWriter xmlWriter)
        {
            // Create an adaptor.

            var adaptor = new XmlWriteAdaptor(xmlWriter, Constants.Xml.Namespace);

            adaptor.WriteStartElement(Constants.Xml.EventMessageElement);

            // Add the XSI namespace if not already there.

            adaptor.WriteNamespace(Constants.Xsi.Prefix, Constants.Xsi.Namespace);
            adaptor.WriteNamespace(Constants.Xml.UtilityPrefix, Constants.Xml.UtilityNamespace);
            adaptor.WriteNamespace(Constants.Xml.TypePrefix, Constants.Xml.TypeNamespace);

            // Add contents.

            WriteXml(adaptor);

            adaptor.WriteEndElement();
        }
Exemple #20
0
        private static void WriteInnerException(XmlWriteAdaptor adaptor, System.Exception innerException)
        {
            adaptor.WriteStartElement(Constants.Xml.Exception.InnerExceptionElement);

            // InnerException.

            if (innerException == null)
            {
                adaptor.WriteAttribute(Constants.Xsi.NilAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, true);
            }
            else
            {
                // Determine whether the exception is serializable itself.

                if (innerException is IXmlSerializable)
                {
                    adaptor.WriteAttribute(Constants.Xml.Exception.ClassAttribute, innerException.GetType().AssemblyQualifiedName);
                    ((IXmlSerializable)innerException).WriteOuterXml(adaptor.XmlWriter);
                }
                else
                {
                    // The class to write out depends on whether or not this is a SystemException.

                    if (innerException is SystemException)
                    {
                        adaptor.WriteAttribute(Constants.Xml.Exception.ClassAttribute, ((SystemException)innerException).Class);
                    }
                    else
                    {
                        adaptor.WriteAttribute(Constants.Xml.Exception.ClassAttribute, innerException.GetType().AssemblyQualifiedName);
                    }

                    adaptor.WriteAttribute(Constants.Xml.Exception.IsSystemAttribute, true);
                    WriteSystemException(adaptor, innerException);
                }
            }

            adaptor.WriteEndElement();
        }
Exemple #21
0
        private static void WriteSystemException(XmlWriteAdaptor adaptor, System.Exception exception)
        {
            // Write out the root element, adding appropriate namespace and type attributes.

            adaptor.WriteStartElement(Constants.Xml.Exception.ExceptionElement);
            adaptor.WriteAttribute(Constants.Xsi.TypeAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, "Exception");

/*
 *          if ( exception is SystemException )
 *                              adaptor.WriteAttribute(Constants.Xml.ClassAttribute, ((SystemException) exception).Class);
 *                      else
 *                              adaptor.WriteAttribute(Constants.Xml.ClassAttribute, exception.GetType().AssemblyQualifiedName);
 */

            // Standard properties.

            adaptor.WriteElement(Constants.Xml.Exception.MessageElement, exception.Message);
            adaptor.WriteElement(Constants.Xml.Exception.SourceElement, exception.Source);
            WriteInnerException(adaptor, exception.InnerException);
            adaptor.WriteElement(Constants.Xml.Exception.StackTraceElement, exception.StackTrace);

            adaptor.WriteEndElement();
        }
Exemple #22
0
        internal void WriteXml(XmlWriteAdaptor adaptor)
        {
            // The name becomes the name of the element.

            adaptor.WriteStartElement(Constants.Xml.ParameterElement);
            adaptor.WriteName(m_name);

            switch (m_valueFormat)
            {
            case ValueFormat.SystemXml:
            case ValueFormat.LinkMeXml:

                WriteXmlFormat(adaptor);
                break;

            case ValueFormat.String:

                WriteStringFormat(adaptor);
                break;

            case ValueFormat.SystemBinary:
            case ValueFormat.LinkMeBinary:

                // Unpack before writing.

                Unpack();
                WriteRawFormat(adaptor);
                break;

            case ValueFormat.Raw:

                WriteRawFormat(adaptor);
                break;
            }

            adaptor.WriteEndElement();
        }
Exemple #23
0
 internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
 {
     adaptor.WriteStartElement(elementName);
     adaptor.WriteElement(Constants.Xml.HttpDetail.Session.IdElement, _id);
     adaptor.WriteEndElement();
 }
Exemple #24
0
        internal void WriteXml(XmlWriteAdaptor adaptor, string elementName)
        {
            adaptor.WriteStartElement(elementName);

            adaptor.WriteEndElement();
        }