Making the plugins behave more stable, fixing a part of Bug #3528518

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1899 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-23 09:21:02 +00:00
commit 2d88d8e588
5 changed files with 98 additions and 47 deletions

View file

@ -68,6 +68,28 @@ namespace Greenshot.Helpers {
RegisteredDestinations.Add(destination.Designation, destination);
}
/// <summary>
/// Method to get all the destinations from the plugins
/// </summary>
/// <returns>List<IDestination></returns>
private static List<IDestination> GetPluginDestinations() {
List<IDestination> destinations = new List<IDestination>();
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;
}
/// <summary>
/// Get a list of all destinations, registered or supplied by a plugin
/// </summary>
@ -75,12 +97,7 @@ namespace Greenshot.Helpers {
public static List<IDestination> GetAllDestinations() {
List<IDestination> destinations = new List<IDestination>();
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;