Exemplo n.º 1
0
        internal string FormatEvent(EventStack stack, EventRecord eventRecord)
        {
            string unusedEventType;
            string unusedEventText;

            return(this.FormatEvent(stack, eventRecord, out unusedEventType, out unusedEventText));
        }
Exemplo n.º 2
0
        internal EventDefinition(EventDefinitionDescription description, EventStack stack)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            this.description = description;
            this.stack       = stack;
        }
Exemplo n.º 3
0
        internal string FormatEvent(EventStack stack, EventRecord eventRecord, out string eventType, out string eventText, int formatVersion = 0)
        {
            eventType = null;
            eventText = null;

            EventDefinitionDescription eventDef;

            if (!this.events.TryGetValue(eventRecord.EventHeader.EventDescriptor.Id, out eventDef))
            {
                return(null);
            }

            return(eventDef.FormatEvent(stack, eventRecord, this.valueMaps, out eventType, out eventText, formatVersion));
        }
Exemplo n.º 4
0
        public ProviderDefinition(ProviderDefinitionDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            this.description = description;
            this.stack       = new EventStack();

            this.events = new Dictionary <int, EventDefinition>();
            this.stack  = new EventStack();

            foreach (var eventDefinitionDescription in description.Events)
            {
                this.events.Add(eventDefinitionDescription.Key, new EventDefinition(eventDefinitionDescription.Value, this.stack));
            }
        }
        internal string FormatEvent(EventStack stack, EventRecord eventRecord, ValueMaps valueMaps, out string eventType, out string eventText, int formatVersion)
        {
            try
            {
                // This inefficient code is only a placeholder
                // once we make it work on all primitive types this will be
                // pre-compiled Linq Expression EventRecord->String
                ApplicationDataReader reader = new ApplicationDataReader(eventRecord.UserData, eventRecord.UserDataLength);

                eventType = this.eventName;
                string type = this.originalEventName;
                string id   = string.Empty;

                string[] values = new string[fields.Count];
                for (int i = 0; i < this.fields.Count; i++)
                {
                    FieldDefinition fieldDef = this.fields[i];
                    values[i] = fieldDef.FormatField(CultureInfo.InvariantCulture, reader, valueMaps);
                }

                if (this.isParentEvent)
                {
                    for (int i = this.fields.Count - 1; i >= 0; i--)
                    {
                        if (this.fields[i].IsContextField)
                        {
                            values[i] = stack.Pop(eventRecord.EventHeader.ProcessId, eventRecord.EventHeader.ThreadId, values[i], this.firstContextFieldIndex == i);
                            if (values[i] == null)
                            {
                                values[i] = " !!!Context Data Not Found!!! ";
                            }
                        }
                    }
                }

                if (this.typeFieldIndex != -1)
                {
                    type = eventType = values[typeFieldIndex];
                }

                eventText = FormatWithFieldValues(values, out id);

                if (id.Length > 0)
                {
                    type += "@" + id;
                }

                if (this.isChildEvent)
                {
                    stack.Push(eventRecord.EventHeader.ProcessId, eventRecord.EventHeader.ThreadId, values[0], eventText);
                    return(null);
                }

                return(EventFormatter.FormatEvent(
                           string.IsNullOrEmpty(this.eventSourceName) ? (EventFormatter.FormatVersion)formatVersion : EventFormatter.FormatVersion.EventSourceBasedFormatting,
                           CultureInfo.InvariantCulture,
                           eventRecord,
                           this.eventSourceName,
                           this.level,
                           this.taskName,
                           this.opcodeName,
                           this.keywordsName,
                           type,
                           eventText));
            }
            catch (Exception e)
            {
                throw new InvalidDataException(
                          string.Format(CultureInfo.InvariantCulture, "Unable to parse event {0}.{1} id {2} eventsource {3}", this.TaskName, this.EventName, this.id, this.eventSourceName),
                          e);
            }
        }