LoadLibraries() private méthode

private LoadLibraries ( AssemblyResolver resolver, Hashtable visited, IEnumerable libraries ) : void
resolver AssemblyResolver
visited System.Collections.Hashtable
libraries IEnumerable
Résultat void
Exemple #1
0
        void Read(XmlDocument doc)
        {
            loading = true;

            try {
                Close();

                XmlNode node = doc.SelectSingleNode("/stetic-interface");
                if (node == null)
                {
                    throw new ApplicationException(Catalog.GetString("Not a Stetic file according to node name."));
                }

                // Load the assembly directories
                resolver = new AssemblyResolver(app);
                app.LoadLibraries(resolver, widgetLibraries);

                if (ownedGlobalActionGroups)
                {
                    foreach (XmlElement groupElem in node.SelectNodes("action-group"))
                    {
                        AddActionGroup(groupElem);
                    }
                }

                XmlElement iconsElem = node.SelectSingleNode("icon-factory") as XmlElement;
                if (iconsElem != null)
                {
                    iconFactory.Read(this, iconsElem);
                }

                foreach (XmlElement toplevel in node.SelectNodes("widget"))
                {
                    AddWidget(toplevel);
                }
            } finally {
                loading = false;
            }
        }
        void Read(XmlDocument doc)
        {
            loading = true;
            string basePath = fileName != null?Path.GetDirectoryName(fileName) : null;

            try {
                string fn = fileName;
                Close();
                fileName = fn;

                XmlNode node = doc.SelectSingleNode("/stetic-interface");
                if (node == null)
                {
                    throw new ApplicationException(Catalog.GetString("Not a Stetic file according to node name."));
                }

                // Load configuration options
                foreach (XmlNode configNode in node.SelectNodes("configuration/*"))
                {
                    XmlElement config = configNode as XmlElement;
                    if (config == null)
                    {
                        continue;
                    }

                    if (config.LocalName == "images-root-path")
                    {
                        imagesRootPath = config.InnerText;
                    }
                    else if (config.LocalName == "target-gtk-version")
                    {
                        targetGtkVersion = config.InnerText;
                    }
                }

                // Load the assembly directories
                resolver = new AssemblyResolver(app);
                foreach (XmlElement libElem in node.SelectNodes("import/assembly-directory"))
                {
                    string dir = libElem.GetAttribute("path");
                    if (dir.Length > 0)
                    {
                        if (basePath != null && !Path.IsPathRooted(dir))
                        {
                            dir = Path.Combine(basePath, dir);
                            if (Directory.Exists(dir))
                            {
                                dir = Path.GetFullPath(dir);
                            }
                        }
                        resolver.Directories.Add(dir);
                    }
                }

                // Import the referenced libraries
                foreach (XmlElement libElem in node.SelectNodes("import/widget-library"))
                {
                    string libname = libElem.GetAttribute("name");
                    if (libname.EndsWith(".dll") || libname.EndsWith(".exe"))
                    {
                        if (basePath != null && !Path.IsPathRooted(libname))
                        {
                            libname = Path.Combine(basePath, libname);
                            if (File.Exists(libname))
                            {
                                libname = Path.GetFullPath(libname);
                            }
                        }
                    }
                    widgetLibraries.Add(libname);
                    if (libElem.GetAttribute("internal") == "true")
                    {
                        internalLibs.Add(libname);
                    }
                }

                app.LoadLibraries(resolver, widgetLibraries);

                ObjectReader reader = new ObjectReader(this, FileFormat.Native);

                if (ownedGlobalActionGroups)
                {
                    foreach (XmlElement groupElem in node.SelectNodes("action-group"))
                    {
                        Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup();
                        actionGroup.Read(reader, groupElem);
                        actionGroups.Add(actionGroup);
                    }
                }

                XmlElement iconsElem = node.SelectSingleNode("icon-factory") as XmlElement;
                if (iconsElem != null)
                {
                    iconFactory.Read(this, iconsElem);
                }

                foreach (XmlElement toplevel in node.SelectNodes("widget"))
                {
                    topLevels.Add(new WidgetData(toplevel.GetAttribute("id"), toplevel, null));
                }
            } finally {
                loading = false;
            }
        }