Ejemplo n.º 1
0
        public Module GetModule(string uri, string path)
        {
            Console.WriteLine($"Installing module from the Internet at {uri}..."); // displays a message
            ShellCore.DownloadFileEx(uri, path);
            ShellCore.ExtractZipFile("Module.zip", "Modules");
            XmlDocument ModuleXml = ShellCore.XmlOpenFile("Modules/Module.xml");

            Console.WriteLine($"Reading Module XML file...");
            XmlNode moduleRoot = ModuleXml.FirstChild;
            string  Name       = moduleRoot.Name;

            if (Name == "#comment")
            {
                while (Name == "#comment")
                {
                    moduleRoot = moduleRoot.NextSibling; // get the next node.
                    Name       = moduleRoot.Name;        // get the next node until we have an actual node.
                }
            }

            if (Name != "Module")
            {
                ShellCore.ElmThrowException(55);
            }

            Module Module = new Module();

            foreach (XmlNode attribute in moduleRoot.ChildNodes)
            {
                switch (attribute.Name)
                {
                case "Name":     // module name
                    Module.Name = attribute.InnerText;
                    continue;

                case "Author":     // module author
                    Module.Author = attribute.InnerText;
                    continue;

                case "Version":     // module version
                    Module.Version = attribute.InnerText;
                    continue;

                case "Copyright":     // module copyright
                    Module.Copyright = attribute.InnerText;
                    continue;

                case "Website":     // module website
                    Module.Website = attribute.InnerText;
                    continue;

                case "Dll":     // module dll
                    Module.Dll = attribute.InnerText;
                    continue;

                case "Extends":     // which dll does this module extend
                    string trimmedExtends = attribute.InnerText.Trim();
                    switch (trimmedExtends)
                    {
                    case "shlcore":
                    case "Shlcore":
                    case "shlCore":
                    case "ShlCore":
                    case "shellcore":
                    case "Shellcore":
                    case "shellCore":
                    case "ShellCore":
                        Module.Extends = Extends.ShellCore;
                        continue;

                    case "shlui":
                    case "Shlui":
                    case "shlUi":
                    case "ShlUi":
                    case "ShlUI":
                    case "shellui":
                    case "ShellUi":
                    case "shellUI":
                    case "ShellUI":
                    case "shellUi":
                    case "Shellui":
                    case "shelluI":
                        Module.Extends = Extends.ShellUI;
                        continue;

                    default:
                        ShellCore.ElmThrowException(57);
                        return(Module);
                    }
                }
            }
            return(Module);
        }