Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 private void CacheProperties()
 {
     if ((this.m_data.Properties == null) && this.m_cacheUpdatable)
     {
         if (this.m_compositeProperties == null)
         {
             this.CreateCompositeProperties();
         }
         PropertiesDictionary dictionary2 = new PropertiesDictionary();
         IEnumerator          enumerator  = ((IEnumerable)this.m_compositeProperties.Flatten()).GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 DictionaryEntry current = (DictionaryEntry)enumerator.Current;
                 string          key     = current.Key as string;
                 if (key != null)
                 {
                     object          fixedObject = current.Value;
                     IFixingRequired required    = fixedObject as IFixingRequired;
                     if (required != null)
                     {
                         fixedObject = required.GetFixedObject();
                     }
                     if (fixedObject != null)
                     {
                         dictionary2[key] = fixedObject;
                     }
                 }
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         this.m_data.Properties = dictionary2;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 缓存数据
        /// </summary>
        /// <remarks>
        /// <para>
        /// 将数据缓存到 LoggingEventData 的属性字典中
        /// </para>
        /// </remarks>
        private void CacheProperties()
        {
            if (m_data.Properties == null && this.m_cacheUpdatable)
            {
                if (m_compositeProperties == null)
                {
                    CreateCompositeProperties();
                }

                PropertiesDictionary flattenedProperties = m_compositeProperties.Flatten();

                PropertiesDictionary fixedProperties = new PropertiesDictionary();

                // Validate properties
                foreach (DictionaryEntry entry in flattenedProperties)
                {
                    string key = entry.Key as string;

                    if (key != null)
                    {
                        object val = entry.Value;

                        // Fix any IFixingRequired objects
                        IFixingRequired fixingRequired = val as IFixingRequired;
                        if (fixingRequired != null)
                        {
                            val = fixingRequired.GetFixedObject();
                        }

                        // Strip keys with null values
                        if (val != null)
                        {
                            fixedProperties[key] = val;
                        }
                    }
                }

                m_data.Properties = fixedProperties;
            }
        }