/// <summary>
        /// Determines whether the specified <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/>
        /// is equal to the current <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/>.
        /// </summary>
        /// <param name='plugin'>
        /// The <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/> to
        /// compare with the current <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/>
        /// is equal to the current <see cref="CyrusBuilt.MonoPluginFramework.AvailablePlugin"/>;
        /// otherwise, <c>false</c>.
        /// </returns>
        public Boolean Equals(AvailablePlugin plugin)
        {
            if (plugin == null) {
                return false;
            }

            if ((Object)plugin == null) {
                return false;
            }

            return ((this._assemblyPath == plugin.AssemblyPath) &&
                    (this._pluginInstance == plugin.Instance));
        }
 /// <summary>
 /// Removes the first occurrence of a specified <see cref="AvailablePlugin"/>
 /// from the collection.
 /// </summary>
 /// <param name="plugin">
 /// The <see cref="AvailablePlugin"/> to remove from the collection.
 /// </param>
 public void Remove(AvailablePlugin plugin)
 {
     base.List.Remove(plugin);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPluginFramework.DuplicatePluginInstanceException"/>
 /// class with the plugin that is a duplicate.
 /// </summary>
 /// <param name="plugin">
 /// The plugin that is an instance duplicate of another.
 /// </param>
 public DuplicatePluginInstanceException(AvailablePlugin plugin)
     : base("Duplicate plugin instance detected: " + plugin.Instance.Name + " v" + plugin.Instance.Version.ToString())
 {
     this._instance = plugin;
 }
 /// <summary>
 /// Determines the index of a specific <see cref="AvailablePlugin"/> in
 /// the collection.
 /// </summary>
 /// <param name="plugin">
 /// The <see cref="AvailablePlugin"/> to locate in the collection.
 /// </param>
 /// <returns>
 /// The index of the <see cref="AvailablePlugin"/> if found in the
 /// collection; Otherwise, -1.
 /// </returns>
 public Int32 IndexOf(AvailablePlugin plugin)
 {
     return base.List.IndexOf(plugin);
 }
 /// <summary>
 /// Inserts a <see cref="AvailablePlugin"/> into the collection at the
 /// specified index.
 /// </summary>
 /// <param name="index">
 /// The zero-based index at which the <see cref="AvailablePlugin"/>
 /// should be inserted.
 /// </param>
 /// <param name="plugin">
 /// The <see cref="AvailablePlugin"/> to insert into the collection.
 /// </param>
 /// <exception cref="DuplicatePluginInstanceException">
 /// An instance of the specified plugin already exists in the collection.
 /// </exception>
 public void Insert(Int32 index, AvailablePlugin plugin)
 {
     if (base.List.Contains(plugin)) {
         throw new DuplicatePluginInstanceException(plugin);
     }
     base.List.Insert(index, plugin);
 }
 /// <summary>
 /// Copies the elements of the collection to a <see cref="AvailablePlugin"/>
 /// array, starting at a particular array index.
 /// </summary>
 /// <param name="array">
 /// The one-dimensional log entry array that is the destination of the
 /// elements copied from the collection.  The location array must have
 /// zero-based indexing.
 /// </param>
 /// <param name="index">
 /// The zero-based index in the array at which copying begins.
 /// </param>
 public void CopyTo(AvailablePlugin[] array, Int32 index)
 {
     base.List.CopyTo(array, index);
 }
 /// <summary>
 /// Determines whether or not the collection contains a specific
 /// <see cref="AvailablePlugin"/>.
 /// </summary>
 /// <param name="plugin">
 /// The <see cref="AvailablePlugin"/> to locate in the collection.
 /// </param>
 /// <returns>
 /// true if the <see cref="AvailablePlugin"/> is found in the collection;
 /// Otherwise, false.
 /// </returns>
 public Boolean Contains(AvailablePlugin plugin)
 {
     return base.List.Contains(plugin);
 }
 /// <summary>
 /// Adds the specified <see cref="AvailablePlugin"/> to the collection
 /// if it is not already in the collection.
 /// </summary>
 /// <param name="plugin">
 /// The plugin to add to the collection.
 /// </param>
 /// <returns>
 /// If successful, the zero-based index position into which the plugin
 /// was added; Otherwise, -1.
 /// </returns>			
 public Int32 Add(AvailablePlugin plugin)
 {
     if (!base.List.Contains(plugin)) {
         return base.List.Add(plugin);
     }
     return -1;
 }
        /// <summary>
        /// Loads the specified plugin and adds it to the managed plugin
        /// collection.
        /// </summary>
        /// <param name="file">
        /// The assembly (*.dll file) that is the plugin.
        /// </param>
        private void AddPlugin(FileInfo file)
        {
            if ((file == null) || (!file.Exists)) {
                return;
            }

            Type typeInterface = null;
            IPlugin instance = null;
            AvailablePlugin newPlugin = null;
            Assembly pluginAssembly = Assembly.LoadFrom(file.FullName);
            foreach (Type pluginType in pluginAssembly.GetTypes()) {
                if ((pluginType.IsPublic) && (!pluginType.IsAbstract)) {
                    typeInterface = pluginType.GetInterface("CyrusBuilt.MonoPluginFramework.IPlugin", true);
                    if (typeInterface != null) {
                        // Load the assembly instance if it is a valid plugin.
                        instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));

                        // Initialize the plugin and add it to the managed collection.
                        newPlugin = new AvailablePlugin(instance, file.FullName);
                        newPlugin.Instance.Host = this;
                        newPlugin.Instance.Initialize();
                        this._plugins.Add(newPlugin);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the plugin's configuration dialog.
 /// </summary>
 /// <param name="plugin">
 /// The plugin to get the configuration from.
 /// </param>
 /// <returns>
 /// A dialog form containing the settings read from the specified
 /// plugin's configuration.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="plugin"/> cannot be null.
 /// </exception>
 public FormPluginSettingsDialog GetConfigurationDialog(AvailablePlugin plugin)
 {
     if (plugin == null) {
         throw new ArgumentNullException("plugin");
     }
     return new FormPluginSettingsDialog(plugin, null);
 }