예제 #1
0
 private static EventDescriptor CreateEventDescriptor(ProviderMetadata providerMetaData, EventMetadata emd)
 {
     long keywords = 0L;
     foreach (EventKeyword keyword in emd.Keywords)
     {
         keywords |= keyword.Value;
     }
     byte channel = 0;
     foreach (EventLogLink link in providerMetaData.LogLinks)
     {
         if (string.Equals(link.LogName, emd.LogLink.LogName, StringComparison.OrdinalIgnoreCase))
         {
             break;
         }
         channel = (byte) (channel + 1);
     }
     return new EventDescriptor((int) emd.Id, emd.Version, channel, (byte) emd.Level.Value, (byte) emd.Opcode.Value, emd.Task.Value, keywords);
 }
예제 #2
0
        private bool VerifyTemplate(EventMetadata emd)
        {
            if (emd.Template != null)
            {
                XmlReaderSettings readerSettings = new XmlReaderSettings
                {
                    CheckCharacters = false,
                    IgnoreComments = true,
                    IgnoreProcessingInstructions = true,
                    MaxCharactersInDocument = 0, // no limit
                    ConformanceLevel = ConformanceLevel.Fragment,
#if !CORECLR
                    XmlResolver = null,
#endif
                };

                int definedParameterCount = 0;
                using (XmlReader reader = XmlReader.Create(new StringReader(emd.Template), readerSettings))
                {
                    if (reader.ReadToFollowing(TemplateTag))
                    {
                        bool found = reader.ReadToDescendant(DataTag);
                        while (found)
                        {
                            definedParameterCount++;
                            found = reader.ReadToFollowing(DataTag);
                        }
                    }
                }

                if ((_payload == null && definedParameterCount != 0)
                    || ((_payload != null) && _payload.Length != definedParameterCount))
                {
                    string warning = string.Format(CultureInfo.InvariantCulture, _resourceMgr.GetString("PayloadMismatch"), _id, emd.Template);
                    WriteWarning(warning);

                    return false;
                }
            }
            return true;
        }
예제 #3
0
 private bool VerifyTemplate(EventMetadata emd)
 {
     if (emd.Template != null)
     {
         XmlReaderSettings settings = new XmlReaderSettings {
             CheckCharacters = false,
             IgnoreComments = true,
             IgnoreProcessingInstructions = true,
             MaxCharactersInDocument = 0L,
             XmlResolver = null,
             ConformanceLevel = ConformanceLevel.Fragment
         };
         int num = 0;
         using (XmlReader reader = XmlReader.Create(new StringReader(emd.Template), settings))
         {
             if (reader.ReadToFollowing("template"))
             {
                 for (bool flag = reader.ReadToDescendant("data"); flag; flag = reader.ReadToFollowing("data"))
                 {
                     num++;
                 }
             }
         }
         if (((this.payload == null) && (num != 0)) || ((this.payload != null) && (this.payload.Length != num)))
         {
             string text = string.Format(CultureInfo.InvariantCulture, this._resourceMgr.GetString("PayloadMismatch"), new object[] { this.id, emd.Template });
             base.WriteWarning(text);
             return false;
         }
     }
     return true;
 }