public IEventTraceOperand Build(int eventMetadataTableIndex) { foreach (var instrumentationManifestTypeItem in this.manifest.Items) { var instrumentationType = instrumentationManifestTypeItem as InstrumentationType; if (instrumentationType != null) { foreach (var instrumentationTypeItem in instrumentationType.Items) { var eventTypes = instrumentationTypeItem as EventsType; if (eventTypes != null) { foreach (var eventTypeItem in eventTypes.Items) { var providerType = eventTypeItem as ProviderType; if (providerType != null) { var providerName = providerType.name; var providerGuid = new Guid(providerType.guid); foreach (var providerTypeItem in providerType.Items) { var definitionType = providerTypeItem as DefinitionType; if (definitionType != null) { foreach (EventDefinitionType definitionTypeItem in definitionType.Items) { if (string.Equals(definitionTypeItem.value, this.eventId.ToString("D"))) { string task = definitionTypeItem.task == null ? string.IsNullOrEmpty(definitionTypeItem.symbol) ? "Task" : definitionTypeItem.symbol : definitionTypeItem.task.Name; string opcode = definitionTypeItem.opcode == null ? string.Empty : definitionTypeItem.opcode.Name; string version = definitionTypeItem.version; string template = definitionTypeItem.template; string name = providerName + "/" + task + (opcode == string.Empty ? string.Empty : "/" + opcode); var properties = new List<IEventTracePropertyOperand>(); foreach (var item in providerType.Items) { var templateList = item as TemplateListType; if (templateList != null) { foreach (var templateTid in templateList.template) { if (string.Equals(templateTid.tid, template)) { int i = 0; foreach (DataDefinitionType propertyItem in templateTid.Items) { var inType = Extensions.ToTdhInType(propertyItem.inType.Name); var outType = TDH_OUT_TYPE.TDH_OUTTYPE_NOPRINT; var metadata = new PropertyMetadata(inType, outType, propertyItem.name, false, false, 0, null); properties.Add(new EventTracePropertyOperand(metadata, i++, false, false, false, false, false)); } } } } } var operand = new EventTraceOperand( new EventMetadata( providerGuid, this.eventId, byte.Parse(version), name, properties.Select(t => t.Metadata).ToArray()), eventMetadataTableIndex, properties); return operand; } } } } } } } } } } return null; }
public IEventTraceOperand Build(int eventMetadataTableIndex) { var strings = manifest.Items .OfType <LocalizationType>().SelectMany(x => x.Items) .OfType <LocalizationTypeResources>().SelectMany(x => x.Items) .OfType <StringTableType>().SelectMany(x => x.Items) .OfType <StringTableTypeString>().ToDictionary(x => x.id, x => x.value); foreach (var instrumentationManifestTypeItem in this.manifest.Items) { var instrumentationType = instrumentationManifestTypeItem as InstrumentationType; if (instrumentationType != null) { foreach (var instrumentationTypeItem in instrumentationType.Items) { var eventTypes = instrumentationTypeItem as EventsType; if (eventTypes != null) { foreach (var eventTypeItem in eventTypes.Items) { var providerType = eventTypeItem as ProviderType; if (providerType != null) { var providerName = providerType.name; var providerGuid = new Guid(providerType.guid); foreach (var providerTypeItem in providerType.Items) { var definitionType = providerTypeItem as DefinitionType; if (definitionType != null) { foreach (EventDefinitionType definitionTypeItem in definitionType.Items) { if (string.Equals(definitionTypeItem.value, this.eventId.ToString("D"))) { string task = definitionTypeItem.task == null?string.IsNullOrEmpty(definitionTypeItem.symbol) ? "Task" : definitionTypeItem.symbol : definitionTypeItem.task.Name; string opcode = definitionTypeItem.opcode == null ? string.Empty : definitionTypeItem.opcode.Name; string version = definitionTypeItem.version; string template = definitionTypeItem.template; string messageKey = definitionTypeItem.message == null ? "" : definitionTypeItem.message.Replace("$(string.", "").TrimEnd(')'); strings.TryGetValue(messageKey, out string message); string name = providerName + "/" + task + (opcode == string.Empty ? string.Empty : "/" + opcode); var properties = new List <IEventTracePropertyOperand>(); foreach (var item in providerType.Items) { var templateList = item as TemplateListType; if (templateList != null) { foreach (var templateTid in templateList.template) { if (string.Equals(templateTid.tid, template)) { int i = 0; foreach (DataDefinitionType propertyItem in templateTid.Items) { var inType = Extensions.ToTdhInType(propertyItem.inType.Name); var outType = TDH_OUT_TYPE.TDH_OUTTYPE_NOPRINT; var metadata = new PropertyMetadata(inType, outType, propertyItem.name, false, false, 0, null); properties.Add(new EventTracePropertyOperand(metadata, i++, false, false, false, false, false)); } } } } } var operand = new EventTraceOperand( new EventMetadata( providerGuid, this.eventId, byte.Parse(version), name, properties.Select(t => t.Metadata).ToArray(), message), eventMetadataTableIndex, properties); return(operand); } } } } } } } } } } return(null); }