private void CacheProperties() { if (m_data.Properties == null && m_cacheUpdatable) { if (m_compositeProperties == null) { CreateCompositeProperties(); } PropertiesDictionary propertiesDictionary = m_compositeProperties.Flatten(); PropertiesDictionary propertiesDictionary2 = new PropertiesDictionary(); foreach (DictionaryEntry item in (IEnumerable)propertiesDictionary) { string text = item.Key as string; if (text != null) { object obj = item.Value; IFixingRequired fixingRequired = obj as IFixingRequired; if (fixingRequired != null) { obj = fixingRequired.GetFixedObject(); } if (obj != null) { propertiesDictionary2[text] = obj; } } } m_data.Properties = propertiesDictionary2; } }
/// <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="Mammothcode.Public.Core.Util.PatternConverter.Option"/> /// property. /// </para> /// <para> /// If the <see cref="Mammothcode.Public.Core.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()); } }
/// <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="log4net.Util.PatternConverter.Option"/> /// property. /// </para> /// <para> /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c> /// then all the properties are written as key value pairs. /// </para> /// </remarks> protected override void Convert(TextWriter writer, object state) { var compositeProperties = new CompositeProperties(); var logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false); if (logicalThreadProperties != null) compositeProperties.Add(logicalThreadProperties); var 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()); } }
/// <summary> /// Write the property value to the output /// </summary> /// <param name="writer"><see cref="T:System.IO.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="P:log4net.Util.PatternConverter.Option" /> /// property. /// </para> /// <para> /// If the <see cref="P:log4net.Util.PatternConverter.Option" /> is set to <c>null</c> /// then all the properties are written as key value pairs. /// </para> /// </remarks> protected override void Convert(TextWriter writer, object state) { CompositeProperties compositeProperties = new CompositeProperties(); PropertiesDictionary properties = LogicalThreadContext.Properties.GetProperties(create: false); if (properties != null) { compositeProperties.Add(properties); } PropertiesDictionary properties2 = ThreadContext.Properties.GetProperties(create: false); if (properties2 != null) { compositeProperties.Add(properties2); } compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties()); if (Option != null) { PatternConverter.WriteObject(writer, null, compositeProperties[Option]); } else { PatternConverter.WriteDictionary(writer, null, compositeProperties.Flatten()); } }
protected override void Convert(TextWriter writer, object state) { CompositeProperties properties = new CompositeProperties(); PropertiesDictionary dictionary = ThreadContext.Properties.GetProperties(false); if (dictionary != null) { properties.Add(dictionary); } properties.Add(GlobalContext.Properties.GetReadOnlyProperties()); if (this.Option != null) { WriteObject(writer, null, properties[this.Option]); } else { WriteDictionary(writer, null, properties.Flatten()); } }