コード例 #1
0
 // Methods
 static Instrumentation()
 {
     m_Configurator = new Configurator();
       m_EventSinks = new EventSinkBag();
       m_EventCategories = new EventCategoryBag();
       m_Filters = new EventFilterBag();
       m_EventSources = new EventSourceFilterBag();
       m_Cache = new Hashtable();
       m_ThreadNameCache = new Hashtable();
       m_EventAsms = new EventAssemblyBag();
       m_Configurator.ConfigRootTag = "instrumentation";
       AppDomain.CurrentDomain.ProcessExit += new EventHandler(DisposeEventSinks);
       AppDomain.CurrentDomain.DomainUnload += new EventHandler(DisposeEventSinks);
 }
コード例 #2
0
 // Methods
 public EventCategorySink(EventCategory category)
 {
     m_EventSinks = new EventSinkBag();
       m_Category = category;
 }
コード例 #3
0
 public static EventSinkBag GetEventSinkBindings(Type eventType, string source)
 {
     StringBuilder builder1 = new StringBuilder(100);
       builder1.AppendFormat("{0}|{1}", eventType.FullName, source);
       EventSinkBag bag1 = (EventSinkBag) m_Cache[builder1.ToString()];
       if ((bag1 == null) && !m_Cache.ContainsKey(builder1.ToString()))
       {
     bag1 = new EventSinkBag();
     int num1 = -1;
     EventSourceFilter filter1 = null;
     foreach (EventSourceFilter filter2 in m_EventSources.Values)
     {
       if (filter2.Enabled)
       {
     int num2 = MatchEventSource(filter2.EventSource, source);
     if (num2 > num1)
     {
       num1 = num2;
       filter1 = filter2;
     }
       }
     }
     if (num1 >= 0)
     {
       foreach (EventFilter filter3 in filter1.EventFilters.Values)
       {
     if (filter3.Enabled)
     {
       foreach (EventCategorySink sink1 in filter3.CategoryBindings.Values)
       {
         if (sink1.Category.IsCompatible(eventType))
         {
           foreach (EventSink sink2 in sink1.EventSinks.Values)
           {
             if (!bag1.ContainsKey(sink2.Name))
             {
               bag1.Add(sink2.Name, sink2);
             }
           }
         }
       }
     }
       }
     }
     if ((bag1 != null) && (bag1.Count == 0))
     {
       bag1 = null;
     }
     lock (m_Cache)
     {
       if (!m_Cache.ContainsKey(builder1.ToString()))
       {
     m_Cache.Add(builder1.ToString(), bag1);
       }
     }
       }
       return bag1;
 }
コード例 #4
0
 public static XmlDocument GetEventSinkBindingInfo(Type eventType, string source)
 {
     EventSinkBag bag1 = new EventSinkBag();
       XmlDocument document1 = new XmlDocument();
       XmlElement element1 = document1.CreateElement("BindingInfo");
       document1.AppendChild(element1);
       XmlElement element2 = document1.CreateElement("input");
       element1.AppendChild(element2);
       XmlAttribute attribute1 = document1.CreateAttribute("eventType");
       attribute1.Value = eventType.ToString();
       element2.Attributes.Append(attribute1);
       XmlAttribute attribute2 = document1.CreateAttribute("source");
       attribute2.Value = source;
       element2.Attributes.Append(attribute2);
       XmlElement element3 = document1.CreateElement("eventSourceAnalysis");
       element1.AppendChild(element3);
       XmlAttribute attribute3 = document1.CreateAttribute("bestRank");
       element3.Attributes.Append(attribute3);
       XmlAttribute attribute4 = document1.CreateAttribute("bestMatch");
       element3.Attributes.Append(attribute4);
       int num1 = -1;
       EventSourceFilter filter1 = null;
       foreach (EventSourceFilter filter2 in m_EventSources.Values)
       {
     XmlElement element4 = document1.CreateElement("eventSource");
     XmlAttribute attribute5 = document1.CreateAttribute("name");
     attribute5.Value = filter2.EventSource;
     element4.Attributes.Append(attribute5);
     element3.AppendChild(element4);
     if (filter2.Enabled)
     {
       int num2 = MatchEventSource(filter2.EventSource, source);
       XmlAttribute attribute6 = document1.CreateAttribute("rank");
       attribute6.Value = num2.ToString();
       element4.Attributes.Append(attribute6);
       if (num2 > num1)
       {
     num1 = num2;
     filter1 = filter2;
       }
     }
     else
     {
       XmlAttribute attribute7 = document1.CreateAttribute("ignored");
       attribute7.Value = "true";
       element4.Attributes.Append(attribute7);
     }
       }
       attribute3.Value = num1.ToString();
       attribute4.Value = (filter1 == null) ? "No match" : filter1.EventSource;
       if (num1 >= 0)
       {
     XmlElement element5 = document1.CreateElement("filterAnalysis");
     element1.AppendChild(element5);
     foreach (EventFilter filter3 in filter1.EventFilters.Values)
     {
       XmlElement element6 = document1.CreateElement("filter");
       XmlAttribute attribute8 = document1.CreateAttribute("name");
       attribute8.Value = filter3.Name;
       element6.Attributes.Append(attribute8);
       element5.AppendChild(element6);
       if (filter3.Enabled)
       {
     foreach (EventCategorySink sink1 in filter3.CategoryBindings.Values)
     {
       XmlElement element7 = document1.CreateElement("eventCategory");
       XmlAttribute attribute9 = document1.CreateAttribute("name");
       attribute9.Value = sink1.Category.Name;
       element7.Attributes.Append(attribute9);
       XmlAttribute attribute10 = document1.CreateAttribute("compatible");
       element7.Attributes.Append(attribute10);
       element6.AppendChild(element7);
       if (sink1.Category.IsCompatible(eventType))
       {
         attribute10.Value = "true";
         foreach (EventSink sink2 in sink1.EventSinks.Values)
         {
           XmlElement element8 = document1.CreateElement("eventSink");
           XmlAttribute attribute11 = document1.CreateAttribute("name");
           attribute11.Value = sink2.Name;
           element8.Attributes.Append(attribute11);
           XmlAttribute attribute12 = document1.CreateAttribute("addToList");
           element8.Attributes.Append(attribute12);
           element7.AppendChild(element8);
           if (!bag1.ContainsKey(sink2.Name))
           {
             attribute12.Value = "new";
             bag1.Add(sink2.Name, sink2);
           }
           else
           {
             attribute12.Value = "alreadyInList";
           }
         }
       }
       else
       {
         attribute10.Value = "false";
       }
     }
       }
       else
       {
     XmlAttribute attribute13 = document1.CreateAttribute("ignored");
     attribute13.Value = "true";
     element6.Attributes.Append(attribute13);
       }
     }
       }
       XmlElement element9 = document1.CreateElement("result");
       element1.AppendChild(element9);
       foreach (EventSink sink3 in bag1.Values)
       {
     XmlElement element10 = document1.CreateElement("eventSink");
     XmlAttribute attribute14 = document1.CreateAttribute("name");
     element10.Attributes.Append(attribute14);
     attribute14.Value = sink3.Name;
     element9.AppendChild(element10);
       }
       return document1;
 }