/// <summary> /// Removes the first occurrence of the given PluginWrapper. /// </summary> /// <param name="plugin">PluginWrapper object to remove.</param> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public void Remove(PluginWrapper plugin) { __List.Remove(plugin); }
/// <summary> /// Determines whether a PluginWrapper exists in the collection. /// </summary> /// <param name="plugin">The PluginWrapper to locate in the collection.</param> /// <returns></returns> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public bool Contains(PluginWrapper plugin) { return __List.Contains(plugin); }
/// <summary> /// Inserts a PluginWrapper at the given index. /// </summary> /// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="plugin">The PluginWrapper to insert.</param> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public void Insert(int index, PluginWrapper plugin) { __List.Insert(index, plugin); }
/// <summary> /// Adds a PluginWrapper to the end of the collection. /// </summary> /// <param name="plugin">The PluginWrapper to add to the end of the collection.</param> /// <returns>Position that the PluginWrapper was inserted.</returns> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public int Add(PluginWrapper plugin) { return __List.Add(plugin); }
/// <summary> /// Determines whether a PluginWrapper exists in the collection. /// </summary> /// <param name="plugin">The PluginWrapper to locate in the collection.</param> /// <returns></returns> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public bool Contains(PluginWrapper plugin) { return(__List.Contains(plugin)); }
/// <summary> /// Adds a PluginWrapper to the end of the collection. /// </summary> /// <param name="plugin">The PluginWrapper to add to the end of the collection.</param> /// <returns>Position that the PluginWrapper was inserted.</returns> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public int Add(PluginWrapper plugin) { return(__List.Add(plugin)); }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="wrapper">Plugin to add (PluginWrapper)</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(PluginWrapper wrapper) { return __PluginCollection.Add(wrapper); }
/// <summary> /// Load a plugin from file. /// </summary> /// <param name="path">Full file path to plugin</param> /// <returns>PluginWrapper containing plugin</returns> /// <history> /// [Curtis_Beard] 09/08/2006 Created /// [Curtis_Beard] 06/28/2007 CHG: make all plugins external and enabled by default /// </history> private static PluginWrapper LoadPlugin(string path) { try { Assembly dll = Assembly.LoadFrom(path); Type objInterface; // Loop through each type in the DLL foreach (Type objType in dll.GetTypes()) { // Only look at public types if (objType.IsPublic) { // Ignore abstract classes if (!((objType.Attributes & TypeAttributes.Abstract) == TypeAttributes.Abstract)) { // See if this type implements our interface objInterface = objType.GetInterface("FileSearchBase.IFileSearchPlugin", true); if (objInterface != null) { // Load dll // Create and return class instance object objPlugin = dll.CreateInstance(objType.FullName); IFileSearchPlugin plugin = (IFileSearchPlugin)objPlugin; PluginWrapper wrapper = new PluginWrapper(plugin, path, dll.FullName, false, true); return wrapper; } } } } } catch {} return null; }
/// <summary> /// Load the plugins. /// </summary> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// [Curtis_Beard] 08/07/2007 CHG: remove check against version /// </history> public static void Load() { // for right now, just load the internal plugins Plugins.MicrosoftWord.MicrosoftWordPlugin wordPlugin = new Plugins.MicrosoftWord.MicrosoftWordPlugin(); PluginWrapper wrapper = new PluginWrapper(wordPlugin, string.Empty, wordPlugin.Name, true, true); Add(wrapper); // enable/disable plugins based on saved state (if found) string[] plugins = Common.SplitByString(Core.PluginSettings.Plugins, Constants.PLUGIN_SEPARATOR); foreach (string plugin in plugins) { string[] values = Common.SplitByString(plugin, Constants.PLUGIN_ARGS_SEPARATOR); if (values.Length == 3) { string name = values[0]; string version = values[1]; string enabled = values[2]; for (int i = 0; i < __PluginCollection.Count; i++) { if (__PluginCollection[i].Plugin.Name.Equals(name)) { __PluginCollection[i].Enabled = bool.Parse(enabled); break; } } } } }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IFileSearchPlugin)</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(IFileSearchPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true); return __PluginCollection.Add(wrapper); }