Exemplo n.º 1
0
        private static Component ParseComponent(XmlDocument xml)
        {
            /*
             * XmlNamespaceManager nsman = new XmlNamespaceManager(xml.NameTable);
             * nsman.AddNamespace("wix", "http://schemas.microsoft.com/wix/2006/wi");
             * string xpath = "/wix:Wix/wix:Fragment/wix:Directory/wix:Component";
             * XmlNodeList xmlComponents = xml.SelectNodes(xpath, nsman);
             *
             * if(xmlComponents.Count == 0)
             *      throw new InvalidOperationException(string.Format("Could not find the WiX component at “{0}”.", xpath));
             * if(xmlComponents.Count > 1)
             *      throw new InvalidOperationException(string.Format("Expected one WiX component at “{0}”, found {1}.", xpath, xmlComponents.Count));
             *
             * XmlNode xmlComponent = xmlComponents[0];
             */

            var            reader        = new CodeDomReader();
            ISchemaElement schemaElement = CodeDomReader_CreateObjectFromElement(reader, xml.DocumentElement);

            CodeDomReader_ParseObjectFromElement(reader, schemaElement, xml.DocumentElement);

            var wix          = (Wix)schemaElement;
            var wixFragment  = ExpectChild <Fragment>(wix);
            var wixDirectory = ExpectChild <Directory>(wixFragment);
            var wixComponent = ExpectChild <Component>(wixDirectory);

            return(wixComponent);
        }
Exemplo n.º 2
0
 private static void CodeDomReader_ParseObjectFromElement(CodeDomReader reader, ISchemaElement element, XmlNode node)
 {
     reader.GetType().InvokeMember("ParseObjectFromElement", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, reader, new object[] { element, node });
 }
Exemplo n.º 3
0
 private static ISchemaElement CodeDomReader_CreateObjectFromElement(CodeDomReader reader, XmlNode node)
 {
     return((ISchemaElement)reader.GetType().InvokeMember("CreateObjectFromElement", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, reader, new object[] { node }));
 }