Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 /// <summary>
 /// Add a plugin to the collection.
 /// </summary>
 /// <param name="plugin">Plugin to add (IAstroGrepPlugin)</param>
 /// <returns>Position of plugin in collection</returns>
 /// <history>
 /// [Curtis_Beard]		07/28/2006	Created
 /// </history>
 public static int Add(IAstroGrepPlugin plugin)
 {
     PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true);
      return __PluginCollection.Add(wrapper);
 }
Beispiel #5
0
        /// <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));
        }
Beispiel #6
0
        /// <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
        /// </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("AstroGrepBase.IAstroGrepPlugin", true);
                     if (objInterface != null)
                     {
                        // Load dll
                        // Create and return class instance
                        object objPlugin = dll.CreateInstance(objType.FullName);

                        IAstroGrepPlugin plugin = (IAstroGrepPlugin)objPlugin;
                        PluginWrapper wrapper = new PluginWrapper(plugin, path, dll.FullName, true, false);

                        return wrapper;
                     }
                  }
               }
            }
             }
             catch {}

             return null;
        }
Beispiel #7
0
 /// <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);
 }
Beispiel #8
0
        /// <summary>
        /// Load the plugins.
        /// </summary>
        /// <history>
        /// [Curtis_Beard]		07/28/2006	Created
        /// </history>
        public static void Load()
        {
            // for right now, just load the internal plugins
             MicrosoftWordPlugin wordPlugin = new 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].Plugin.Version.Equals(version))
                  {
                     __PluginCollection[i].Enabled = bool.Parse(enabled);
                     break;
                  }
               }
            }
             }
        }
Beispiel #9
0
 /// <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);
 }
Beispiel #10
0
 /// <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);
 }
Beispiel #11
0
 /// <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);
 }
Beispiel #12
0
 /// <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);
 }