private void WriteValueInfo(XmlWriteAdaptor adaptor, string className, ValueFormat valueFormat) { adaptor.WriteAttribute(Constants.Xml.ClassAttribute, className); string format; switch (valueFormat) { case ValueFormat.LinkMeXml: format = Constants.Xml.LinkMeFormat; break; case ValueFormat.SystemXml: format = Constants.Xml.SystemFormat; break; case ValueFormat.String: format = Constants.Xml.StringFormat; break; default: format = string.Empty; break; } adaptor.WriteAttribute(Constants.Xml.FormatAttribute, format); }
private void WriteStringParameter(XmlWriteAdaptor adaptor) { // Write out a default ToString element. WriteValueInfo(adaptor, new ClassInfo(m_value.GetType()), ValueFormat.String); adaptor.WriteElementValue(m_value.ToString()); }
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(); }
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(); }
public void WriteXsiTypeAttribute(XmlWriteAdaptor adaptor) { const string method = "WriteXsiTypeAttribute"; if (adaptor == null) { throw new NullParameterException(GetType(), method, "adaptor"); } if (m_xmlTypeQualifiedName.Namespace == Constants.Xml.Namespace) { // Get the LinkMe Type prefix or write it if not found. string prefix = adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace); adaptor.WriteAttribute(Constants.Xsi.TypeAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, prefix + ":" + m_xmlTypeQualifiedName.Name); } else { // XSD type - no prefix. adaptor.WriteAttribute(Constants.Xsi.TypeAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, m_xmlTypeQualifiedName.Name); } }
public void WriteXml(XmlWriter writer) { var adaptor = new XmlWriteAdaptor(writer, Constants.Xml.Namespace); adaptor.WriteNamespace(Constants.Xml.Namespace); WriteXml(adaptor); }
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(); } }
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(); }
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(); }
public void WriteOuterXml(XmlWriter writer) { var adaptor = new XmlWriteAdaptor(writer); adaptor.WriteStartElement(OuterElement); WriteXml(adaptor); writer.WriteEndElement(); // </exception> }
public void WriteOuterXml(XmlWriter writer) { XmlWriteAdaptor adaptor = new XmlWriteAdaptor(writer, Constants.Xml.Namespace); adaptor.WriteStartElement(Constants.Xml.NetDetail.Name); WriteXml(adaptor); adaptor.WriteEndElement(); }
public void WriteXml(XmlWriter xmlWriter) { XmlWriteAdaptor adaptor = new XmlWriteAdaptor(xmlWriter, GetXmlNamespace()); adaptor.WriteNamespace("lm", GetXmlNamespace()); WriteNamespaces(adaptor); adaptor.WriteAttribute(Constants.Xsi.TypeAttribute, Constants.Xsi.Prefix, Constants.Xsi.Namespace, GetType().Name); WriteXml(adaptor); }
private void WriteXml(XmlWriteAdaptor adaptor) { adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace); adaptor.WriteElement(Constants.Xml.SecurityDetail.ProcessUserNameElement, m_processUserName); adaptor.WriteElement(Constants.Xml.SecurityDetail.AuthenticationTypeElement, m_authenticationType); adaptor.WriteElement(Constants.Xml.SecurityDetail.IsAuthenticatedElement, XmlConvert.ToString(m_isAuthenticated)); adaptor.WriteElement(Constants.Xml.SecurityDetail.UserNameElement, m_userName); }
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(); }
private void WriteXml(XmlWriteAdaptor adaptor) { adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace); adaptor.WriteElement(Constants.Xml.ProcessDetail.ProcessIdElement, XmlConvert.ToString(_processId)); adaptor.WriteElement(Constants.Xml.ProcessDetail.ProcessNameElement, _processName); adaptor.WriteElement(Constants.Xml.ProcessDetail.MachineNameElement, _machineName); adaptor.WriteElement(Constants.Xml.ProcessDetail.CommandLineArgsElement, _commandLineArgs); }
private void WriteXml(XmlWriteAdaptor adaptor) { adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace); adaptor.WriteName(_name); foreach (var value in _values) { adaptor.WriteElement(value.Name, (value.Value ?? string.Empty).ToString()); } }
private void WriteXml(XmlWriteAdaptor adaptor) { // Iterate through each message. foreach (IXmlSerializable message in m_messages) { message.WriteOuterXml(adaptor.XmlWriter); } }
public void WriteXml(XmlWriter xmlWriter) { // Create an adaptor. var adaptor = new XmlWriteAdaptor(xmlWriter, Constants.Xml.Namespace); // Add contents. WriteXml(adaptor); }
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(); }
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(); }
private void WriteXmlFormat(XmlWriteAdaptor adaptor) { WriteValueInfo(adaptor, m_class, m_valueFormat); // Need to read in the value in the string. XmlTextReader reader = new XmlTextReader(new StringReader((string)m_value)); reader.MoveToContent(); adaptor.XmlWriter.WriteNode(reader, true); }
public void WriteXml(XmlWriter writer) { if (writer.WriteState != WriteState.Element) { throw new System.InvalidOperationException(typeof(ExceptionInfo).Name + ".WriteXml() expects the start" + " of the outer element to have been written. Did you mean to call WriteOuterXml() instead?"); } var adaptor = new XmlWriteAdaptor(writer); WriteXml(adaptor); }
private bool WriteNullParameter(XmlWriteAdaptor adaptor) { if (m_value != null) { return(false); } // Apply the xsi:nil attribute. adaptor.WriteXsiNilAttribute(true); return(true); }
private void WriteXml(XmlWriteAdaptor adaptor) { adaptor.WriteNamespace(Constants.Xml.Prefix, Constants.Xml.Namespace); adaptor.WriteElement(Constants.Xml.ThreadDetail.ThreadId, XmlConvert.ToString(m_threadId)); adaptor.WriteElement(Constants.Xml.ThreadDetail.ApartmentState, m_apartmentState.ToString()); adaptor.WriteElement(Constants.Xml.ThreadDetail.Culture, m_culture); adaptor.WriteElement(Constants.Xml.ThreadDetail.ThreadName, m_threadName); adaptor.WriteElement(Constants.Xml.ThreadDetail.State, m_state.ToString()); adaptor.WriteElement(Constants.Xml.ThreadDetail.Priority, m_priority.ToString()); adaptor.WriteElement(Constants.Xml.ThreadDetail.IsThreadPoolThread, XmlConvert.ToString(m_isThreadPoolThread)); adaptor.WriteElement(Constants.Xml.ThreadDetail.Sequence, XmlConvert.ToString(m_sequence)); }
public void WriteXml(XmlWriter xmlWriter) { XmlWriteAdaptor adaptor = new XmlWriteAdaptor(xmlWriter, Constants.Xml.Namespace); // Add the XSI namespace. adaptor.WriteNamespace(Constants.Xsi.Prefix, Constants.Xsi.Namespace); adaptor.WriteNamespace(Constants.Xml.TypePrefix, Constants.Xml.TypeNamespace); // Write the messages. WriteXml(adaptor); }
private void WriteXml(XmlWriteAdaptor adaptor) { // Standard. adaptor.WriteElement(Constants.Xml.Exception.MessageElement, Message); adaptor.WriteElement(Constants.Xml.Exception.SourceElement, Source); adaptor.WriteElement(Constants.Xml.Exception.MethodElement, Method); adaptor.WriteElement(Constants.Xml.Exception.TimeElement, XmlConvert.ToString(m_time, XmlDateTimeSerializationMode.Utc)); WriteInnerException(adaptor, InnerException); adaptor.WriteElement(Constants.Xml.Exception.StackTraceElement, StackTrace); WriteDetails(adaptor); WriteContents(adaptor); }
private void WriteParameter(XmlWriteAdaptor adaptor) { if (WriteLinkMeXmlParameter(adaptor)) { return; } if (WriteSystemXmlParameter(adaptor)) { return; } WriteStringParameter(adaptor); }
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(); }
private bool WriteLinkMeXmlParameter(XmlWriteAdaptor adaptor) { // Ask the object to serialize itself using the IXmlSerializable interface. IXmlSerializable serializable = m_value as IXmlSerializable; if (serializable == null) { return(false); } WriteValueInfo(adaptor, new ClassInfo(m_value.GetType()), ValueFormat.LinkMeXml); serializable.WriteOuterXml(adaptor.XmlWriter); return(true); }
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); }