/// <summary> /// Creates a one-dimensional <see cref="T:System.Array">Array</see> instance containing the collection items. /// </summary> /// <returns>Array of type IPlugin</returns> public IImageManipulationPlugin[] ToArray() { IImageManipulationPlugin[] array = new IImageManipulationPlugin[this.Count]; this.CopyTo(array, 0); return(array); }
/// <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 plugin 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) { PluginCollection plugins = new PluginCollection(); foreach (XmlNode node in section.ChildNodes) { try { //Use the Activator class's 'CreateInstance' method //to try and create an instance of the plugin 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 IPlugin interface and add to the collection IImageManipulationPlugin plugin = (IImageManipulationPlugin)plugObject; plugins.Add(plugin); } catch (Exception e) { //Catch any exceptions //but continue iterating for more plugins } } return(plugins); }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="PluginCollection">PluginCollection</see>. /// </summary> /// <param name="value">The <see cref="PluginCollection">PluginCollection</see> to search for in the collection.</param> /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns> public bool Contains(IImageManipulationPlugin value) { return(this.List.Contains(value)); }
public int Add(IImageManipulationPlugin value) { return(this.List.Add(value)); }
public void Remove(IImageManipulationPlugin value) { List.Remove(value); }
public void Insert(int index, IImageManipulationPlugin value) { List.Insert(index, value); }
/// <summary> /// Gets the index in the collection of the specified <see cref="PluginCollection">PluginCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="PluginCollection">PluginCollection</see> to locate in the collection.</param> /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns> public int IndexOf(IImageManipulationPlugin value) { return(this.List.IndexOf(value)); }