// BaseClass hbclas = new BaseClass(); //TheDarkOwlLogger.TheDarkOwlLogger hdBugger = new TheDarkOwlLogger.TheDarkOwlLogger(); //static public ScrablerPluginCollection Loaded_ScrablerPlugins ; /// <summary> /// Iterate through all the child nodes /// of the XMLNode that was passed in and create instances /// of the specified Types by reading the attribite values of the nodes /// we use a try/Catch here because some of the nodes /// might contain an invalid reference to a ScrablerPlugin type /// </summary> /// <param name="parent"></param> /// <param name="configContext"></param> /// <param name="section">The XML section we will iterate against</param> /// <returns></returns> public object Create(object parent, object configContext, System.Xml.XmlNode section) { ScrablerPluginCollection Loaded_ScrablerPlugins = new ScrablerPluginCollection(); foreach (XmlNode node in section.ChildNodes) { try { //Use the Activator class's 'CreateInstance' method //to try and create an instance of the ScrablerPlugin by //passing in the type name specified in the attribute value object plugObject = Activator.CreateInstance(Type.GetType(node.Attributes["type"].Value)); //Cast this to an ScrablerPluginSDK interface and add to the collection ScrablerPluginSDK ScrablerPlugin = (ScrablerPluginSDK)plugObject; Loaded_ScrablerPlugins.Add(ScrablerPlugin); } catch (Exception e) { //MessageBox.Show(e.ToString()); //hbclas.errorhandling(e); //Catch any exceptions //but continue iterating for more ScrablerPlugins Program.Bugtracking(e); } } return(Loaded_ScrablerPlugins); }
/* * public ScrablerPluginSDK FindAScrablerPluginBasedOnKind(ScrablerPluginCollection plugcoll, string ScrablerPluginkind) * { * try * { * ScrablerPluginSDK plug = null; * int i; * if ((plugcoll != null) || (ScrablerPluginkind != null)) * { * for (i = 0; i < plugcoll.Count; i++) * { * * plug = plugcoll[i]; * break; * * * * } * * * } * return plug; * * } * catch (Exception e) * { * * Program.Bugtracking(e); * return null; * } * * } * public ScrablerPluginCollection FindAScrablerPluginsBasedOnKind(ScrablerPluginCollection plugcoll, string ScrablerPluginkind) * { * try * { * ScrablerPluginCollection plug = null; * int i; * if ((plugcoll != null) || (ScrablerPluginkind != null)) * { * plug = new ScrablerPluginCollection(); * for (i = 0; i < plugcoll.Count; i++) * { * * plug.Add(plugcoll[i]); * * * * * } * * * } * return plug; * * } * catch (Exception e) * { * * Program.Bugtracking(e); * return null; * } * * } */ /// <summary> /// Copies the plugin with the given name from on plugin collection to other one /// </summary> /// <param name="source">source plugin colelction</param> /// <param name="target">target plugin collection</param> /// <param name="plugname">name of plugin name</param> public void CopyScrablerPlugin(ScrablerPluginCollection source, ScrablerPluginCollection target, string plugname) { try { ScrablerPluginSDK plg; if ((source != null) || (target != null) || (plugname != null)) { plg = this.FindAScrablerPlugin(source, plugname); target.Add(plg); } } catch (Exception e) { Program.Bugtracking(e); } }