private static IDictionary <int, string> GetEventMessageDictionary(Type eventSourceType)
        {
            Dictionary <int, string> nums = new Dictionary <int, string>();

            MethodInfo[]         methods         = eventSourceType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            EventSourceAttribute customAttribute = (EventSourceAttribute)Attribute.GetCustomAttribute(eventSourceType, typeof(EventSourceAttribute), false);
            ResourceManager      resourceManager = new ResourceManager(customAttribute.LocalizationResources, eventSourceType.Assembly);

            for (int i = 0; i < (int)methods.Length; i++)
            {
                MethodInfo methodInfo = methods[i];
                methodInfo.GetParameters();
                EventAttribute eventAttribute = (EventAttribute)Attribute.GetCustomAttribute(methodInfo, typeof(EventAttribute), false);
                if (eventAttribute != null)
                {
                    string str = methodInfo.Name.Replace("EventWrite", string.Empty);
                    nums[eventAttribute.EventId] = resourceManager.GetString(string.Concat("event_", str));
                }
            }
            return(nums);
        }
Ejemplo n.º 2
0
 public void StartEvent(string eventName, EventAttribute eventAttribute)
 {
     this.templateName = string.Concat(eventName, "Args");
     this.numParams    = 0;
     this.events.Append("  <event").Append(" symbol=\"").Append(eventName).Append("\"").Append(" value=\"").Append(eventAttribute.EventId).Append("\"").Append(" version=\"").Append(eventAttribute.Version).Append("\"").Append(" level=\"").Append(ManifestBuilder.GetLevelName(eventAttribute.Level)).Append("\"");
     this.WriteMessageAttrib(this.events, "event", eventName, eventAttribute.Message);
     if (eventAttribute.Keywords != EventKeywords.None)
     {
         ulong channelKeyword = ~this.GetChannelKeyword(eventAttribute.Channel) & (ulong)eventAttribute.Keywords;
         this.events.Append(" keywords=\"").Append(this.GetKeywords(channelKeyword, eventName)).Append("\"");
     }
     if (eventAttribute.Opcode != EventOpcode.Info)
     {
         this.events.Append(" opcode=\"").Append(this.GetOpcodeName(eventAttribute.Opcode, eventName)).Append("\"");
     }
     if (eventAttribute.Task != EventTask.None)
     {
         this.events.Append(" task=\"").Append(this.GetTaskName(eventAttribute.Task, eventName)).Append("\"");
     }
     if (eventAttribute.Channel != EventChannel.Default)
     {
         this.events.Append(" channel=\"").Append(this.GetChannelName(eventAttribute.Channel, eventName)).Append("\"");
     }
 }