Beispiel #1
0
        private static void SetupAddIn(XmlTextReader reader, AddIn addIn, string hintPath)
        {
            while (reader.Read())
            {
                string str3;
                string localName;
                if ((reader.NodeType == XmlNodeType.Element) && reader.IsStartElement())
                {
                    localName = reader.LocalName;
                    switch (localName)
                    {
                        case "StringResources":
                        case "BitmapResources":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("BitmapResources requires ONE attribute.");
                            }
                            break;

                        case "Runtime":
                            if (reader.IsEmptyElement)
                            {
                                goto Label_02E9;
                            }
                            goto Label_01DB;

                        case "Include":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("Include requires ONE attribute.");
                            }
                            goto Label_020B;

                        case "Path":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("Import node requires ONE attribute.");
                            }
                            goto Label_0293;

                        case "Manifest":
                            addIn.Manifest.ReadManifestSection(reader, hintPath);
                            goto Label_02E9;

                        default:
                            throw new AddInLoadException("Unknown root path node:" + reader.LocalName);
                    }
                    string item = SkyMap.Net.Core.StringParser.Parse(reader.GetAttribute("file"));
                    if (reader.LocalName == "BitmapResources")
                    {
                        addIn.BitmapResources.Add(item);
                    }
                    else
                    {
                        addIn.StringResources.Add(item);
                    }
                }
                goto Label_02E9;
            Label_014B:
                if ((reader.NodeType == XmlNodeType.EndElement) && (reader.LocalName == "Runtime"))
                {
                    goto Label_02E9;
                }
                if ((reader.NodeType == XmlNodeType.Element) && reader.IsStartElement())
                {
                    localName = reader.LocalName;
                    if ((localName == null) || !(localName == "Import"))
                    {
                        throw new AddInLoadException("Unknown node in runtime section :" + reader.LocalName);
                    }
                    addIn.runtimes.Add(Runtime.Read(addIn, reader, hintPath));
                }
            Label_01DB:
                if (reader.Read())
                {
                    goto Label_014B;
                }
                goto Label_02E9;
            Label_020B:
                if (!reader.IsEmptyElement)
                {
                    throw new AddInLoadException("Include nodes must be empty!");
                }
                if (hintPath == null)
                {
                    throw new AddInLoadException("Cannot use include nodes when hintPath was not specified (e.g. when AddInManager reads a .addin file)!");
                }
                string url = Path.Combine(hintPath, reader.GetAttribute(0));
                using (XmlTextReader reader2 = new XmlTextReader(url))
                {
                    SetupAddIn(reader2, addIn, Path.GetDirectoryName(url));
                }
                goto Label_02E9;
            Label_0293:
                str3 = reader.GetAttribute(0);
                ExtensionPath extensionPath = addIn.GetExtensionPath(str3);
                if (!reader.IsEmptyElement)
                {
                    ExtensionPath.SetUp(extensionPath, reader, "Path");
                }
            Label_02E9:;
            }
        }