in Source/Tx.Windows.TypeGeneration/ManifestParser.cs [23:85]
public ManifestParser(string manifest)
{
XElement localization;
XElement resources = null;
_root = XElement.Parse(manifest);
_instrumentation = _root.Element(ElementNames.Instrumentation);
if (_instrumentation == null)
{
_instrumentation = _root.Element(ElementNames.Instrumentation1);
localization = _root.Element(ElementNames.Localization1);
if (localization != null)
resources = localization.Element(ElementNames.Resources1);
if (resources != null)
_stringTable = resources.Element(ElementNames.StringTable1);
}
else
{
localization = _root.Element(ElementNames.Localization);
if (localization != null)
{
resources = localization.Element(ElementNames.Resources);
if (resources != null)
_stringTable = resources.Element(ElementNames.StringTable);
}
}
_events = _instrumentation.Element(ElementNames.Events);
if (_events == null)
throw new Exception("The element <events> in namespace http://schemas.microsoft.com/win/2004/08/events was not found");
_providers = _events.Elements(ElementNames.Provider);
_code = new Dictionary<string, string>();
foreach (XElement provider in _providers)
{
// Itis unusual that the source attribute is missing. I send mail to Vance
string source = provider.Attribute(AttributeNames.Source) == null
? "Xml"
: provider.Attribute(AttributeNames.Source).Value;
switch (source)
{
case "Xml":
ParseManifestProvider(provider);
break;
case "Wbem":
ParseClassicProvider(provider);
break;
default:
throw new Exception(
String.Format(
"unknown source attribute {0} for provider {1}. The expexted values are Xml and Wbem",
source,
provider.Attribute(AttributeNames.Name).Value));
}
}
}