本文整理汇总了C#中TraceEvent.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# TraceEvent.ToXml方法的具体用法?C# TraceEvent.ToXml怎么用?C# TraceEvent.ToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraceEvent
的用法示例。
在下文中一共展示了TraceEvent.ToXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadSchema
internal static void ReadSchema(TraceEvent manifestEvent)
{
var xElem = XElement.Parse(manifestEvent.ToXml(new StringBuilder()).ToString());
var ns = xElem.DescendantsAndSelf().First(x => x.Name.LocalName != "Event").Name.Namespace;
var guidText = xElem.Descendants(ns + "provider").First().Attribute("guid").Value;
var guid = new Guid(guidText.Replace("{", "").Replace("}", ""));
cache.GetOrAdd(guid, s =>
{
// { tid : { eventId, keywords} }
var tidRef = xElem.Descendants(ns + "event")
.ToDictionary(x => x.Attribute("template").Value, x => new
{
EventId = int.Parse(x.Attribute("value").Value),
Keywords = x.Attribute("keywords")?.Value ?? ""
});
var dict = xElem.Descendants(ns + "template")
.Select(template => new { template, @event = tidRef[template.Attribute("tid").Value] })
.ToDictionary(
x => [email protected],
x => [email protected]);
return new ReadOnlyDictionary<int, string>(dict);
});
}
示例2: ReadSchema
internal static void ReadSchema(TraceEvent manifestEvent)
{
var xElem = XElement.Parse(manifestEvent.ToXml(new StringBuilder()).ToString());
var ns = xElem.DescendantsAndSelf().First(x => x.Name.LocalName != "Event").Name.Namespace;
var guidText = xElem.Descendants(ns + "provider").First().Attribute("guid").Value;
var guid = new Guid(guidText.Replace("{", "").Replace("}", ""));
cache.GetOrAdd(guid, s =>
{
// { tid : {[payloadNames]}}
var tidRef = xElem.Descendants(ns + "template")
.ToDictionary(x => x.Attribute("tid").Value, x => new ReadOnlyCollection<string>(
x.Elements(ns + "data")
.Select(y => y.Attribute("name").Value)
.ToArray()));
var dict = xElem.Descendants(ns + "event")
.ToDictionary(x => int.Parse(x.Attribute("value").Value),
x => x.Attribute("keywords")?.Value ?? "");
return new ReadOnlyDictionary<int, string>(dict);
});
}