Example #1
0
        object IConfigurationSectionHandler.Create(object parent, object config_context, XmlNode section)
        {
            ManagerConfig  config  = new ManagerConfig();
            AssemblyLoader loader  = new AssemblyLoader();
            HttpContext    context = HttpContext.Current;
            bool           found   = false;

            // Add all dlls in plugin dir
            foreach (string file in this.FindDLLs(context.Request.MapPath(@"plugins"), new ArrayList()))
            {
                //System.Web.HttpContext.Current.Trace.Write(file);

                loader.AddFile(file);
                found = true;
            }

            // Add all dlls in plugin dir
            if (!found)
            {
                foreach (string file in this.FindDLLs(context.Request.MapPath(@"..\plugins"), new ArrayList()))
                {
                    //System.Web.HttpContext.Current.Trace.Write(file);

                    loader.AddFile(file);
                }
            }

            foreach (XmlElement pluginElm in section.SelectNodes("plugins/plugin"))
            {
                // Load plugin dll
                if (pluginElm.GetAttribute("file") != "")
                {
                    loader.AddFile(PathUtils.ToUnixPath(pluginElm.GetAttribute("file")));
                }

                // Add class
                config.Plugins.Add(pluginElm.GetAttribute("class"));
            }

            foreach (XmlElement addElm in section.SelectNodes("config/add"))
            {
                config.Add(addElm.GetAttribute("key"), addElm.GetAttribute("value"));
            }

            return(config);
        }