/// <summary> /// Write the property value to the output /// </summary> /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param> /// <param name="state">null, state is not set</param> /// <remarks> /// <para> /// Writes out the value of a named property. The property name /// should be set in the <see cref="GodLesZ.Library.Logging.Util.PatternConverter.Option"/> /// property. /// </para> /// <para> /// If the <see cref="GodLesZ.Library.Logging.Util.PatternConverter.Option"/> is set to <c>null</c> /// then all the properties are written as key value pairs. /// </para> /// </remarks> override protected void Convert(TextWriter writer, object state) { CompositeProperties compositeProperties = new CompositeProperties(); #if !NETCF PropertiesDictionary logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false); if (logicalThreadProperties != null) { compositeProperties.Add(logicalThreadProperties); } #endif PropertiesDictionary threadProperties = ThreadContext.Properties.GetProperties(false); if (threadProperties != null) { compositeProperties.Add(threadProperties); } // TODO: Add Repository Properties compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties()); if (Option != null) { // Write the value for the specified key WriteObject(writer, null, compositeProperties[Option]); } else { // Write all the key value pairs WriteDictionary(writer, null, compositeProperties.Flatten()); } }
private void CreateCompositeProperties() { m_compositeProperties = new CompositeProperties(); if (m_eventProperties != null) { m_compositeProperties.Add(m_eventProperties); } #if !NETCF PropertiesDictionary logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false); if (logicalThreadProperties != null) { m_compositeProperties.Add(logicalThreadProperties); } #endif PropertiesDictionary threadProperties = ThreadContext.Properties.GetProperties(false); if (threadProperties != null) { m_compositeProperties.Add(threadProperties); } // TODO: Add Repository Properties m_compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties()); }