Ejemplo n.º 1
0
 private static void EnsureOutputsLoaded()
 {
     //DC this is a hack to make sure we can load the subMenus (which on 2nd load were causing an exception)
     try
     {
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             var text = format.Menu.Text;
         }
     }
     catch
     {
         imageOutputCollection = null;
     }
     if (imageOutputCollection == null)
     {
         imageOutputCollection = Plugins.Load();
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             IConfigurablePlugin plugin = format as IConfigurablePlugin;
             if (plugin != null && plugin.Settings != null)
             {
                 object settings = Configuration.Current.RetrieveSettingsForPlugin(plugin.Settings.GetType());
                 if (settings != null)
                 {
                     plugin.Settings = settings;
                 }
             }
         }
     }
 }
        public static ImageOutputCollection Load()
        {
            ImageOutputCollection imageOutputCollection = new ImageOutputCollection();

            IPersistableImageFormat imageFormatPlugin = null;

            //DC load from current Dll
            var assembly = Assembly.GetExecutingAssembly();

            foreach (Type testType in assembly.GetTypes())
            {
                //Look for public types and ignore abstract classes

                if (testType.IsPublic && testType.Attributes != TypeAttributes.Abstract)
                {
                    //Does the type implement the proper interface
                    //
                    if ((testType.GetInterface(PluginInterfaceName, true)) != null && testType.IsClass && !testType.IsAbstract)
                    {
                        object pluginObject = assembly.CreateInstance(testType.FullName);
                        imageFormatPlugin = (IPersistableImageFormat)pluginObject;
                        imageOutputCollection.Add(imageFormatPlugin);
                    }
                }
            }


            /*
             *          foreach (string path in LoadValidAssemblies())
             *          {
             *                  try
             *                  {
             *                          Assembly assembly;
             *                          assembly = Assembly.LoadFrom(path);
             *                          IPersistableImageFormat imageFormatPlugin;
             *                          imageFormatPlugin = ExamineAssembly(assembly);
             *                          if (imageFormatPlugin != null)
             *                                  imageOutputCollection.Add(imageFormatPlugin);
             *                  }
             *                  catch (FileLoadException e)
             *                  {
             *                          Debug.WriteLine(e.Message);
             *                  }
             *          }*/
            return(imageOutputCollection);
        }
Ejemplo n.º 3
0
 private static void EnsureOutputsLoaded()
 {
     if (imageOutputCollection == null)
     {
         imageOutputCollection = Plugins.Load();
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             IConfigurablePlugin plugin = format as IConfigurablePlugin;
             if (plugin != null && plugin.Settings != null)
             {
                 object settings = Configuration.Current.RetrieveSettingsForPlugin(plugin.Settings.GetType());
                 if (settings != null)
                 {
                     plugin.Settings = settings;
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        public static ImageOutputCollection Load()
        {
            ImageOutputCollection imageOutputCollection = new ImageOutputCollection();

            foreach (string path in LoadValidAssemblies())
            {
                try
                {
                    Assembly assembly = Assembly.LoadFrom(path);
                    IPersistableImageFormat imageFormatPlugin = ExamineAssembly(assembly);
                    if (imageFormatPlugin != null)
                    {
                        imageOutputCollection.Add(imageFormatPlugin);
                    }
                }
                catch (FileLoadException e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
            return(imageOutputCollection);
        }