in Source/Tx.Windows.TypeGeneration/ManifestParser.cs [189:254]
private void ParseClassicProvider(XElement provider)
{
string providerName = MakeIdentifier(provider.Attribute(AttributeNames.Name).Value);
XElement templates = provider.Element(ElementNames.Templates);
GetEarliestVersions(provider);
Func<XElement, string> nameFunction = FindNameFunction(provider);
XElement events = provider.Element(ElementNames.Events);
XElement tasks = provider.Element(ElementNames.Tasks);
XElement opcodes = provider.Element(ElementNames.Opcodes);
var sb = new StringBuilder(
@"//
// This code was generated by EtwEventTypeGen.exe
//
using System;");
sb.AppendLine();
sb.AppendLine();
sb.Append("namespace Tx.Windows.");
sb.Append(providerName);
sb.AppendLine();
sb.AppendLine("{");
foreach (XElement evt in events.Elements())
{
string className = nameFunction(evt);
XElement task = (from t in tasks.Elements()
where
evt.Attribute(AttributeNames.Task).Value == t.Attribute(AttributeNames.Name).Value
select t).First();
XElement opcode = (from o in opcodes.Elements()
where
evt.Attribute(AttributeNames.Opcode).Value ==
o.Attribute(AttributeNames.Name).Value
select o).First();
string version = "0";
if (evt.Attribute(AttributeNames.Version) != null)
{
version = evt.Attribute(AttributeNames.Version).Value;
}
sb.AppendFormat(" [ClassicEvent(\"{0}\", {1}, {2})]",
task.Attribute(AttributeNames.EventGuid).Value,
opcode.Attribute(AttributeNames.MofValue).Value,
version);
sb.AppendLine();
sb.AppendFormat(" public class {0}{1} : SystemEvent", className, VersionSuffix(evt));
sb.AppendLine();
sb.AppendLine(" {");
EmitTemplate(ref sb, evt, templates);
sb.AppendLine(" }");
sb.AppendLine();
}
sb.AppendLine("}");
_code.Add(providerName, sb.ToString());
}