Ejemplo n.º 1
0
        internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) 
        {
            InsureInitialized();
            if (m_OutputStreams != null && m_eventCallbackArgs == null)
                m_eventCallbackArgs = new EventWrittenEventArgs(this); 

            m_providerEnabled = enable; 
            m_level = level; 
            m_matchAnyKeyword = matchAnyKeyword;
 
            // Find the per-Provider stream cooresponding to registered outputStream
            EventProviderDataStream providerOutputStream = m_OutputStreams;
            if (providerOutputStream != null)
            { 
                for (; ; )
                { 
                    if (providerOutputStream == null) 
                        throw new ArgumentException("outputStream not found");
                    if (providerOutputStream.m_MasterStream == outputStream) 
                        break;
                    providerOutputStream = providerOutputStream.m_Next;
                }
            } 

            if (enable) 
            { 
                // Send the manifest if the stream once per stream
                if (providerOutputStream != null) 
                {
                    if (!providerOutputStream.m_ManifestSent)
                    {
                        providerOutputStream.m_ManifestSent = true; 
                        SendManifest(m_rawManifest, providerOutputStream);
                    } 
                } 
                else
                { 
                    // providerOutputStream == null means this is the ETW manifest
                    // If we are not completely initalized we can't send the manifest because WriteEvent
                    // will fail (handle was not returned from OS API).  We will try again after the
                    // constuctor completes. 
                    if (!m_ETWManifestSent && m_completelyInited)
                    { 
                        m_ETWManifestSent = true; 
                        SendManifest(m_rawManifest, providerOutputStream);
                    } 
                }
            }
            else
            {   // 
                if (providerOutputStream != null)
                    providerOutputStream.m_ManifestSent = false; 
                else 
                    m_ETWManifestSent = false;
            } 

            // Set it up using the 'standard' filtering bitfields
            for (int i = 0; i < m_eventData.Length; i++)
                SetEnabled(providerOutputStream, i, IsEnabledDefault(i, level, matchAnyKeyword)); 

            if (commandArguments == null) 
                commandArguments = new Dictionary<string, string>(); 

            // Allow subclasses to fiddle with it from there. 
            OnControllerCommand(providerOutputStream, command, commandArguments);

        }
 internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments)
 {
     this.InsureInitialized();
     if ((this.m_OutputStreams != null) && (this.m_eventCallbackArgs == null))
     {
         this.m_eventCallbackArgs = new EventWrittenEventArgs(this);
     }
     this.m_providerEnabled = enable;
     this.m_level = level;
     this.m_matchAnyKeyword = matchAnyKeyword;
     EventProviderDataStream outputStreams = this.m_OutputStreams;
     if (outputStreams == null)
     {
         goto Label_0062;
     }
 Label_0042:
     if (outputStreams == null)
     {
         throw new ArgumentException("outputStream not found");
     }
     if (outputStreams.m_MasterStream != outputStream)
     {
         outputStreams = outputStreams.m_Next;
         goto Label_0042;
     }
 Label_0062:
     if (enable)
     {
         if (outputStreams != null)
         {
             if (!outputStreams.m_ManifestSent)
             {
                 outputStreams.m_ManifestSent = true;
                 this.SendManifest(this.m_rawManifest, outputStreams);
             }
         }
         else if (!this.m_ETWManifestSent && this.m_completelyInited)
         {
             this.m_ETWManifestSent = true;
             this.SendManifest(this.m_rawManifest, outputStreams);
         }
     }
     else if (outputStreams != null)
     {
         outputStreams.m_ManifestSent = false;
     }
     else
     {
         this.m_ETWManifestSent = false;
     }
     for (int i = 0; i < this.m_eventData.Length; i++)
     {
         this.SetEnabled(outputStreams, i, this.IsEnabledDefault(i, level, matchAnyKeyword));
     }
     if (commandArguments == null)
     {
         commandArguments = new Dictionary<string, string>();
     }
     this.OnControllerCommand(outputStreams, command, commandArguments);
 }