diff --git a/Greenshot/Helpers/DestinationHelper.cs b/Greenshot/Helpers/DestinationHelper.cs
index 1e64af517..c8fa7d65a 100644
--- a/Greenshot/Helpers/DestinationHelper.cs
+++ b/Greenshot/Helpers/DestinationHelper.cs
@@ -68,6 +68,28 @@ namespace Greenshot.Helpers {
RegisteredDestinations.Add(destination.Designation, destination);
}
+ ///
+ /// Method to get all the destinations from the plugins
+ ///
+ /// List
+ private static List GetPluginDestinations() {
+ List destinations = new List();
+ foreach (PluginAttribute pluginAttribute in PluginHelper.instance.Plugins.Keys) {
+ IGreenshotPlugin plugin = PluginHelper.instance.Plugins[pluginAttribute];
+ try {
+ var dests = plugin.Destinations();
+ if (dests != null) {
+ destinations.AddRange(dests);
+ }
+ } catch (Exception ex) {
+ LOG.ErrorFormat("Couldn't get destinations from the plugin {0}", pluginAttribute.Name);
+ LOG.Error(ex);
+ }
+ }
+ destinations.Sort();
+ return destinations;
+ }
+
///
/// Get a list of all destinations, registered or supplied by a plugin
///
@@ -75,12 +97,7 @@ namespace Greenshot.Helpers {
public static List GetAllDestinations() {
List destinations = new List();
destinations.AddRange(RegisteredDestinations.Values);
- foreach(IGreenshotPlugin plugin in PluginHelper.instance.Plugins.Values) {
- var dests = plugin.Destinations();
- if (dests != null) {
- destinations.AddRange(dests);
- }
- }
+ destinations.AddRange(GetPluginDestinations());
destinations.Sort();
return destinations;
}
@@ -97,11 +114,9 @@ namespace Greenshot.Helpers {
if (RegisteredDestinations.ContainsKey(designation)) {
return RegisteredDestinations[designation];
}
- foreach(IGreenshotPlugin plugin in PluginHelper.instance.Plugins.Values) {
- foreach(IDestination destination in plugin.Destinations()) {
- if (designation.Equals(destination.Designation)) {
- return destination;
- }
+ foreach (IDestination destination in GetPluginDestinations()) {
+ if (designation.Equals(destination.Designation)) {
+ return destination;
}
}
return null;
diff --git a/Greenshot/Helpers/ProcessorHelper.cs b/Greenshot/Helpers/ProcessorHelper.cs
index c3676d9f8..41625e763 100644
--- a/Greenshot/Helpers/ProcessorHelper.cs
+++ b/Greenshot/Helpers/ProcessorHelper.cs
@@ -39,21 +39,25 @@ namespace Greenshot.Helpers {
if (!"Greenshot.Processors".Equals(ProcessorType.Namespace)) {
continue;
}
- if (!ProcessorType.IsAbstract) {
- IProcessor Processor;
- try {
- Processor = (IProcessor)Activator.CreateInstance(ProcessorType);
- } catch (Exception e) {
- LOG.ErrorFormat("Can't create instance of {0}", ProcessorType);
- LOG.Error(e);
- continue;
- }
- if (Processor.isActive) {
- LOG.DebugFormat("Found Processor {0} with designation {1}", ProcessorType.Name, Processor.Designation);
- RegisterProcessor(Processor);
- } else {
- LOG.DebugFormat("Ignoring Processor {0} with designation {1}", ProcessorType.Name, Processor.Designation);
+ try {
+ if (!ProcessorType.IsAbstract) {
+ IProcessor Processor;
+ try {
+ Processor = (IProcessor)Activator.CreateInstance(ProcessorType);
+ } catch (Exception e) {
+ LOG.ErrorFormat("Can't create instance of {0}", ProcessorType);
+ LOG.Error(e);
+ continue;
+ }
+ if (Processor.isActive) {
+ LOG.DebugFormat("Found Processor {0} with designation {1}", ProcessorType.Name, Processor.Designation);
+ RegisterProcessor(Processor);
+ } else {
+ LOG.DebugFormat("Ignoring Processor {0} with designation {1}", ProcessorType.Name, Processor.Designation);
+ }
}
+ } catch (Exception ex) {
+ LOG.ErrorFormat("Error loading processor {0}, message: ", ProcessorType.FullName, ex.Message);
}
}
}
@@ -67,18 +71,34 @@ namespace Greenshot.Helpers {
RegisteredProcessors.Add(Processor.Designation, Processor);
}
+ private static List GetPluginsProcessors() {
+ List processors = new List();
+ foreach (PluginAttribute pluginAttribute in PluginHelper.instance.Plugins.Keys) {
+ IGreenshotPlugin plugin = PluginHelper.instance.Plugins[pluginAttribute];
+ try {
+ var procs = plugin.Processors();
+ if (procs != null) {
+ processors.AddRange(procs);
+ }
+ } catch (Exception ex) {
+ LOG.ErrorFormat("Couldn't get processors from the plugin {0}", pluginAttribute.Name);
+ LOG.Error(ex);
+ }
+ }
+ processors.Sort();
+ return processors;
+ }
+
///
/// Get a list of all Processors, registered or supplied by a plugin
///
///
public static List GetAllProcessors() {
- List Processors = new List();
- Processors.AddRange(RegisteredProcessors.Values);
- foreach(IGreenshotPlugin plugin in PluginHelper.instance.Plugins.Values) {
- Processors.AddRange(plugin.Processors());
- }
- Processors.Sort();
- return Processors;
+ List processors = new List();
+ processors.AddRange(RegisteredProcessors.Values);
+ processors.AddRange(GetPluginsProcessors());
+ processors.Sort();
+ return processors;
}
///
@@ -93,11 +113,9 @@ namespace Greenshot.Helpers {
if (RegisteredProcessors.ContainsKey(designation)) {
return RegisteredProcessors[designation];
}
- foreach(IGreenshotPlugin plugin in PluginHelper.instance.Plugins.Values) {
- foreach(IProcessor Processor in plugin.Processors()) {
- if (designation.Equals(Processor.Designation)) {
- return Processor;
- }
+ foreach (IProcessor processor in GetPluginsProcessors()) {
+ if (designation.Equals(processor.Designation)) {
+ return processor;
}
}
return null;
diff --git a/GreenshotConfluencePlugin/ConfluenceDestination.cs b/GreenshotConfluencePlugin/ConfluenceDestination.cs
index 58cf86195..efa993b97 100644
--- a/GreenshotConfluencePlugin/ConfluenceDestination.cs
+++ b/GreenshotConfluencePlugin/ConfluenceDestination.cs
@@ -40,19 +40,28 @@ namespace GreenshotConfluencePlugin {
private static ConfluenceConfiguration config = IniConfig.GetIniSection();
private static Image confluenceIcon = null;
private Confluence.Page page;
-
+ public static bool IsInitialized {
+ get;
+ private set;
+ }
static ConfluenceDestination() {
- Uri confluenceIconUri = new Uri("/GreenshotConfluencePlugin;component/Images/Confluence.ico", UriKind.Relative);
- using (Stream iconStream = Application.GetResourceStream(confluenceIconUri).Stream) {
- using (Image tmpImage = Image.FromStream(iconStream)) {
- confluenceIcon = ImageHelper.Clone(tmpImage);
+ IsInitialized = false;
+ try {
+ Uri confluenceIconUri = new Uri("/GreenshotConfluencePlugin;component/Images/Confluence.ico", UriKind.Relative);
+ using (Stream iconStream = Application.GetResourceStream(confluenceIconUri).Stream) {
+ using (Image tmpImage = Image.FromStream(iconStream)) {
+ confluenceIcon = ImageHelper.Clone(tmpImage);
+ }
}
+ IsInitialized = true;
+ } catch (Exception ex) {
+ LOG.ErrorFormat("Problem in the confluence static initializer: {0}", ex.Message);
}
}
public ConfluenceDestination() {
-
}
+
public ConfluenceDestination(Confluence.Page page) {
this.page = page;
}
diff --git a/GreenshotConfluencePlugin/ConfluencePlugin.cs b/GreenshotConfluencePlugin/ConfluencePlugin.cs
index 6fd02ad6a..737536e15 100644
--- a/GreenshotConfluencePlugin/ConfluencePlugin.cs
+++ b/GreenshotConfluencePlugin/ConfluencePlugin.cs
@@ -84,7 +84,11 @@ namespace GreenshotConfluencePlugin {
}
public IEnumerable Destinations() {
- yield return new ConfluenceDestination();
+ if (ConfluenceDestination.IsInitialized) {
+ yield return new ConfluenceDestination();
+ } else {
+ yield break;
+ }
}
public IEnumerable Processors() {
@@ -106,8 +110,13 @@ namespace GreenshotConfluencePlugin {
if(config.IsDirty) {
IniConfig.Save();
}
- TranslationManager.Instance.TranslationProvider = new LanguageXMLTranslationProvider();
- //resources = new ComponentResourceManager(typeof(JiraPlugin));
+ try {
+ TranslationManager.Instance.TranslationProvider = new LanguageXMLTranslationProvider();
+ //resources = new ComponentResourceManager(typeof(JiraPlugin));
+ } catch (Exception ex) {
+ LOG.ErrorFormat("Problem in ConfluencePlugin.Initialize: {0}", ex.Message);
+ return false;
+ }
return true;
}
diff --git a/GreenshotPlugin/Core/InterfaceUtils.cs b/GreenshotPlugin/Core/InterfaceUtils.cs
index dda013442..209512118 100644
--- a/GreenshotPlugin/Core/InterfaceUtils.cs
+++ b/GreenshotPlugin/Core/InterfaceUtils.cs
@@ -49,7 +49,7 @@ namespace GreenshotPlugin.Core {
}
}
} catch (Exception ex) {
- LOG.Warn(ex);
+ LOG.WarnFormat("Problem getting subclasses of type: {0}, message: {1}", type.FullName, ex.Message);
}
}
return list;