コード例 #1
0
        private Configuration.Chunk FindSectionChunk(string name, ref string valueName)
        {
            // First check that the resource is really here.
            if (documentHandle.IsValid)
            {
                if (documentHandle.Resource.RootChunk != null)
                {
                    if (documentHandle.Resource.RootChunk.Name == "Registry")
                    {
                        // Really search for it.
                        string[] parts = name.Split(new char[] { '.' });
                        if (parts.Length > 1)
                        {
                            string[] sectionParts = new string[parts.Length - 1];
                            for (int i = 0; i < parts.Length - 1; i++)
                            {
                                sectionParts[i] = parts[i];
                            }

                            valueName = parts[parts.Length - 1];
                            Configuration.Chunk currentChunk = documentHandle.Resource.RootChunk;

                            // Now recurse.
                            for (int i = 0; i < sectionParts.Length; i++)
                            {
                                currentChunk = currentChunk[sectionParts[i]];

                                if (currentChunk == null)
                                {
                                    break;
                                }
                            }

                            return(currentChunk);
                        }
                    }
                }
            }
            else
            {
                log.Warning("Registry file not found.");

                if (documentHandle.Url != string.Empty)
                {
                    log.Info("Creating new registry file [{0}]", documentHandle.Url);

                    // Create an empty document.
                    Configuration.XmlDocument newDocument =
                        new Configuration.XmlDocument();

                    newDocument.RootChunk = new Configuration.Chunk("Registry");

                    // Write it out.
                    newDocument.Write(documentHandle.Url);
                }
            }
            return(null);
        }
コード例 #2
0
        public System.IO.Stream Open(string url, bool write)
        {
            log.Debug("Trying to open file [{0}] write: {1}", url, write);

            // Find matching archive.
            if (!write)
            {
                if (!Exists(url))
                {
                    log.Warning("Trying to open [{0}] for reading, file does not exist.", url);
                    return(null);
                }
            }

            if (Url.IsFilename(url))
            {
                string  relativeUrl  = url;
                Archive foundArchive = FindArchive(url, ref relativeUrl);

                if (foundArchive != null)
                {
                    System.IO.Stream stream = foundArchive.Open(relativeUrl, write);

                    if (stream != null)
                    {
                        log.Debug("File [{0}] successfully opened for write: {1}", url, write);
                    }
                    return(stream);
                }
                else
                {
                    log.Info("No archive found for url: [{0}][{1}]", url, relativeUrl);
                }
            }
            else
            {
                log.Info("[{0}] is not a file url.", url);
            }

            return(null);
        }
コード例 #3
0
        public void Unload(string name)
        {
            if (loadedAssemblies.ContainsKey(name))
            {
                IPlugin pluginInterface = GetPluginInterface(loadedAssemblies[name]);

                if (pluginInterface.OnUnload(new Information.License(), new Information.Version(), new Information.Platform()))
                {
                    log.Info("Plugin unloaded [{0}]", name);
                    loadedAssemblies.Remove(name);
                }
            }
        }