diff --git a/Greenshot/Destinations/PickerDestination.cs b/Greenshot/Destinations/PickerDestination.cs
index f94c1af98..23bb29175 100644
--- a/Greenshot/Destinations/PickerDestination.cs
+++ b/Greenshot/Destinations/PickerDestination.cs
@@ -48,7 +48,8 @@ namespace Greenshot.Destinations {
/// true if export was made
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
List destinations = new List();
- foreach(IDestination destination in DestinationHelper.GetAllDestinations()) {
+
+ foreach(var destination in SimpleServiceProvider.Current.GetAllInstances()) {
if ("Picker".Equals(destination.Designation)) {
continue;
}
diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs
index a21335c8f..bfb7e2612 100644
--- a/Greenshot/Forms/ImageEditorForm.cs
+++ b/Greenshot/Forms/ImageEditorForm.cs
@@ -223,19 +223,18 @@ namespace Greenshot {
using Pen cbBorderPen = new Pen(SystemColors.ActiveBorder);
// Loop over all items in the propertiesToolStrip
foreach (ToolStripItem item in propertiesToolStrip.Items) {
- ToolStripComboBox cb = item as ToolStripComboBox;
+ var cb = item as ToolStripComboBox;
// Only ToolStripComboBox that are visible
if (cb == null || !cb.Visible) {
continue;
}
- // Calculate the rectangle
- if (cb.ComboBox != null)
- {
- Rectangle r = new Rectangle(cb.ComboBox.Location.X - 1, cb.ComboBox.Location.Y - 1, cb.ComboBox.Size.Width + 1, cb.ComboBox.Size.Height + 1);
+ if (cb.ComboBox == null) continue;
- // Draw the rectangle
- e.Graphics.DrawRectangle(cbBorderPen, r);
- }
+ // Calculate the rectangle
+ Rectangle r = new Rectangle(cb.ComboBox.Location.X - 1, cb.ComboBox.Location.Y - 1, cb.ComboBox.Size.Width + 1, cb.ComboBox.Size.Height + 1);
+
+ // Draw the rectangle
+ e.Graphics.DrawRectangle(cbBorderPen, r);
}
}
@@ -705,12 +704,15 @@ namespace Greenshot {
HelpFileLoader.LoadHelp();
}
- private void AboutToolStripMenuItemClick(object sender, EventArgs e) {
- MainForm.Instance.ShowAbout();
+ private void AboutToolStripMenuItemClick(object sender, EventArgs e)
+ {
+ var mainForm = SimpleServiceProvider.Current.GetInstance();
+ mainForm.ShowAbout();
}
private void PreferencesToolStripMenuItemClick(object sender, EventArgs e) {
- MainForm.Instance.ShowSetting();
+ var mainForm = SimpleServiceProvider.Current.GetInstance();
+ mainForm.ShowSetting();
}
private void BtnSettingsClick(object sender, EventArgs e) {
@@ -1251,7 +1253,8 @@ namespace Greenshot {
private void Insert_window_toolstripmenuitemMouseEnter(object sender, EventArgs e) {
ToolStripMenuItem captureWindowMenuItem = (ToolStripMenuItem)sender;
- MainForm.Instance.AddCaptureWindowMenuItems(captureWindowMenuItem, Contextmenu_window_Click);
+ var mainForm = SimpleServiceProvider.Current.GetInstance();
+ mainForm.AddCaptureWindowMenuItems(captureWindowMenuItem, Contextmenu_window_Click);
}
private void Contextmenu_window_Click(object sender, EventArgs e) {
diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs
index dff93324f..4e768b461 100644
--- a/Greenshot/Forms/MainForm.cs
+++ b/Greenshot/Forms/MainForm.cs
@@ -302,7 +302,6 @@ namespace Greenshot {
}
private static MainForm _instance;
- public static MainForm Instance => _instance;
private readonly CopyData _copyData;
@@ -315,13 +314,18 @@ namespace Greenshot {
// Timer for the double click test
private readonly Timer _doubleClickTimer = new Timer();
- public NotifyIcon NotifyIcon => notifyIcon;
+ public MainForm(CopyDataTransport dataTransport) {
+ // The most important form is this
+ SimpleServiceProvider.Current.AddService
@@ -262,9 +262,9 @@
Schermopname bijsnijden
Als u maar een deel van de schermopname nodig hebt, gebruik dan de functie bijsnijden C
- om overtollige delen weg te snijden.
+ om overtollige delen weg te snijden.
Teken hiertoe een rechthoek om het gebied van de schermopname dat behouden moet worden.
- U kunt de afmetingen van het geselecteerde gebied naar wens aanpassen.
+ U kunt de afmetingen van het geselecteerde gebied naar wens aanpassen.
Bent u tevreden over het geselecteerde gebied, bevestig het bijsnijden dan in de gereedschapsbalk of toets Enter.
U kunt het bijsnijden afbreken met de toets ESC.
@@ -294,7 +294,7 @@
Als u regelmatig dezelfde elementen toepast in de bewerking van uw schermopnamen
(bijv. een tekstkader met browsertype en versienummer, of het maskeren van hetzelfde
- element in verschillende schermopnamen) dan kunt u deze elementen hergebruiken.
+ element in verschillende schermopnamen) dan kunt u deze elementen hergebruiken.
Kies in het menu Objecten, Objecten opslaan om de huidige elementen op te slaan
voor later gebruik. Objecten laden past deze eerder opgeslagen elementen toe
op een andere schermopname.
@@ -331,7 +331,7 @@
Algemene instellingen
-
Taal: De taal waarin Greenshot wordt weergegeven.
+
Taal: De taal waarin Greenshot wordt weergegeven.
Aanvullende taalbestanden zijn te downloaden van de Greenshot website.
Greenshot met Windows opstarten: Start het programma als de PC wordt opgestart.
Sneltoetsen: Hier kunt u de sneltoetsen voor het maken van schermopnames aanpassen.
@@ -414,7 +414,7 @@
Op dit moment zoeken we geen hulp bij de ontwikkeling.
- Maar dit betekent niet dat u niets kunt doen om het Greenshot ontwikkelteam te ondersteunen.
+ Maar dit betekent niet dat u niets kunt doen om het Greenshot ontwikkelteam te ondersteunen.
Bij voorbaat dank :)
@@ -425,8 +425,8 @@
goede software gratis en vrij toegankelijk te houden. Als Greenshot
u helpt in uw werkzaamheden, als het u (of uw bedrijf)
tijd en geld bespaart, of u vindt het gewoon een fijn programma en
- u staat positief tegenover het concept van open source software: Ondersteun ons werk dan met een donatie.
- Bezoek onze website en lees daar hoe u het Greenshot-team kunt ondersteunen:
+ u staat positief tegenover het concept van open source software: Ondersteun ons werk dan met een donatie.
+ Bezoek onze website en lees daar hoe u het Greenshot-team kunt ondersteunen: http://getgreenshot.org/support/
@@ -434,7 +434,7 @@
Vertel het door
Bevalt Greenshot u? Vertel het dan door: vertel uw vrienden en collega's over Greenshot.
- En ook uw aanhang en achterban ! :)
+ En ook uw aanhang en achterban ! :)
Bespreek Greenshot met goede kritieken op software portals of plaats een verwijzing naar Greenshot in uw blog of op uw website.
@@ -443,10 +443,10 @@
Is Greenshot niet beschikbaar in uw favoriete taal en u denkt dat u software kunt vertalen dan bent u van harte welkom!
Als geregisteerde gebruiker bij sourceforge.net kunt u uw vertaling in onze
- vertalings tracker aanmelden.
+ vertalings tracker aanmelden.
Voordat u begint is het verstandig om te kijken of Greenshot niet al in de taal vertaald is, zie de
downloads pagina. Ook kunt u op onze vertalings tracker kijken.
- Het zou namelijk kunnen zijn dat iemand al aan de vertaling werkt of misschien hierover heeft gecommuniceerd.
+ Het zou namelijk kunnen zijn dat iemand al aan de vertaling werkt of misschien hierover heeft gecommuniceerd.
Merk op dat vertalingen alleen kunnen worden geaccepteerd als ze afkomstig zijn van een geregistreerde
sourceforge.net-gebruiker. Wij kunnen niet elke vertaling doorgronden en daarom is het belangrijk dat we
diff --git a/GreenshotBoxPlugin/BoxPlugin.cs b/GreenshotBoxPlugin/BoxPlugin.cs
index ebabaf8a7..18b2b8d0e 100644
--- a/GreenshotBoxPlugin/BoxPlugin.cs
+++ b/GreenshotBoxPlugin/BoxPlugin.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
@@ -33,11 +32,10 @@ namespace GreenshotBoxPlugin {
///
/// This is the Box base code
///
+ [Plugin("Box", true)]
public class BoxPlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(BoxPlugin));
private static BoxConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _itemPlugInConfig;
@@ -46,7 +44,7 @@ namespace GreenshotBoxPlugin {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
+ protected void Dispose(bool disposing) {
if (disposing) {
if (_itemPlugInConfig != null) {
_itemPlugInConfig.Dispose();
@@ -55,35 +53,22 @@ namespace GreenshotBoxPlugin {
}
}
- public IEnumerable Destinations() {
- yield return new BoxDestination(this);
- }
-
-
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute pluginAttribute) {
- _host = pluginHost;
- Attributes = pluginAttribute;
+ public bool Initialize() {
// Register configuration (don't need the configuration itself)
_config = IniConfig.GetIniSection();
_resources = new ComponentResourceManager(typeof(BoxPlugin));
-
+ SimpleServiceProvider.Current.AddService(new BoxDestination(this));
_itemPlugInConfig = new ToolStripMenuItem {
Image = (Image) _resources.GetObject("Box"),
Text = Language.GetString("box", LangKey.Configure)
};
_itemPlugInConfig.Click += ConfigMenuClick;
- PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
+ PluginUtils.AddToContextMenu(_itemPlugInConfig);
Language.LanguageChanged += OnLanguageChanged;
return true;
}
@@ -94,14 +79,14 @@ namespace GreenshotBoxPlugin {
}
}
- public virtual void Shutdown() {
+ public void Shutdown() {
LOG.Debug("Box Plugin shutdown.");
}
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
_config.ShowConfigDialog();
}
@@ -119,7 +104,7 @@ namespace GreenshotBoxPlugin {
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
SurfaceContainer imageToUpload = new SurfaceContainer(surfaceToUpload, outputSettings, filename);
- new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("box", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Box", Language.GetString("box", LangKey.communication_wait),
delegate {
url = BoxUtils.UploadToBox(imageToUpload, captureDetails.Title, filename);
}
diff --git a/GreenshotBoxPlugin/Properties/AssemblyInfo.cs b/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
index 78e96157f..2ccef9573 100644
--- a/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotBoxPlugin/Properties/AssemblyInfo.cs
@@ -27,8 +27,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Box")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotBoxPlugin.BoxPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotConfluencePlugin/ConfluenceDestination.cs b/GreenshotConfluencePlugin/ConfluenceDestination.cs
index 1c42041dd..966c4f4e9 100644
--- a/GreenshotConfluencePlugin/ConfluenceDestination.cs
+++ b/GreenshotConfluencePlugin/ConfluenceDestination.cs
@@ -42,10 +42,6 @@ namespace GreenshotConfluencePlugin {
private static readonly Image ConfluenceIcon;
private readonly Page _page;
- public static bool IsInitialized {
- get;
- private set;
- }
static ConfluenceDestination() {
IsInitialized = false;
try {
@@ -60,7 +56,13 @@ namespace GreenshotConfluencePlugin {
Log.ErrorFormat("Problem in the confluence static initializer: {0}", ex.Message);
}
}
-
+
+ public static bool IsInitialized
+ {
+ get;
+ private set;
+ }
+
public ConfluenceDestination() {
}
diff --git a/GreenshotConfluencePlugin/ConfluencePlugin.cs b/GreenshotConfluencePlugin/ConfluencePlugin.cs
index 651fbeea0..40f4248b6 100644
--- a/GreenshotConfluencePlugin/ConfluencePlugin.cs
+++ b/GreenshotConfluencePlugin/ConfluencePlugin.cs
@@ -24,7 +24,6 @@ using Greenshot.IniFile;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using System;
-using System.Collections.Generic;
using System.Windows;
using TranslationByMarkupExtension;
@@ -42,11 +41,11 @@ namespace GreenshotConfluencePlugin {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
+ protected void Dispose(bool disposing) {
//if (disposing) {}
}
- private static void CreateConfluenceConntector() {
+ private static void CreateConfluenceConnector() {
if (_confluenceConnector == null) {
if (_config.Url.Contains("soap-axis")) {
_confluenceConnector = new ConfluenceConnector(_config.Url, _config.Timeout);
@@ -65,7 +64,7 @@ namespace GreenshotConfluencePlugin {
public static ConfluenceConnector ConfluenceConnector {
get {
if (_confluenceConnector == null) {
- CreateConfluenceConntector();
+ CreateConfluenceConnector();
}
try {
if (_confluenceConnector != null && !_confluenceConnector.IsLoggedIn) {
@@ -78,22 +77,10 @@ namespace GreenshotConfluencePlugin {
}
}
- public IEnumerable Destinations() {
- if (ConfluenceDestination.IsInitialized) {
- yield return new ConfluenceDestination();
- }
- }
-
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
+ public bool Initialize() {
// Register configuration (don't need the configuration itself)
_config = IniConfig.GetIniSection();
if(_config.IsDirty) {
@@ -106,10 +93,14 @@ namespace GreenshotConfluencePlugin {
LOG.ErrorFormat("Problem in ConfluencePlugin.Initialize: {0}", ex.Message);
return false;
}
+ if (ConfluenceDestination.IsInitialized)
+ {
+ SimpleServiceProvider.Current.AddService(new ConfluenceDestination());
+ }
return true;
}
- public virtual void Shutdown() {
+ public void Shutdown() {
LOG.Debug("Confluence Plugin shutdown.");
if (_confluenceConnector != null) {
_confluenceConnector.Logout();
@@ -120,7 +111,7 @@ namespace GreenshotConfluencePlugin {
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
ConfluenceConfiguration clonedConfig = _config.Clone();
ConfluenceConfigurationForm configForm = new ConfluenceConfigurationForm(clonedConfig);
string url = _config.Url;
diff --git a/GreenshotConfluencePlugin/Properties/AssemblyInfo.cs b/GreenshotConfluencePlugin/Properties/AssemblyInfo.cs
deleted file mode 100644
index edc19b7cb..000000000
--- a/GreenshotConfluencePlugin/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using Greenshot.Plugin;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotConfluencePlugin.ConfluencePlugin", true)]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
diff --git a/GreenshotDropboxPlugin/DropboxPlugin.cs b/GreenshotDropboxPlugin/DropboxPlugin.cs
index deea0de44..d75f4704c 100644
--- a/GreenshotDropboxPlugin/DropboxPlugin.cs
+++ b/GreenshotDropboxPlugin/DropboxPlugin.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
@@ -33,11 +32,10 @@ namespace GreenshotDropboxPlugin {
///
/// This is the Dropbox base code
///
+ [Plugin("Dropbox", true)]
public class DropboxPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(DropboxPlugin));
private static DropboxPluginConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _itemPlugInConfig;
@@ -46,7 +44,7 @@ namespace GreenshotDropboxPlugin {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
+ protected void Dispose(bool disposing) {
if (disposing) {
if (_itemPlugInConfig != null) {
_itemPlugInConfig.Dispose();
@@ -55,37 +53,23 @@ namespace GreenshotDropboxPlugin {
}
}
- public IEnumerable Destinations() {
- yield return new DropboxDestination(this);
- }
-
-
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- _host = pluginHost;
- Attributes = myAttributes;
+ public bool Initialize() {
// Register configuration (don't need the configuration itself)
_config = IniConfig.GetIniSection();
_resources = new ComponentResourceManager(typeof(DropboxPlugin));
-
+ SimpleServiceProvider.Current.AddService(new DropboxDestination(this));
_itemPlugInConfig = new ToolStripMenuItem
{
Text = Language.GetString("dropbox", LangKey.Configure),
- Tag = _host,
Image = (Image)_resources.GetObject("Dropbox")
};
_itemPlugInConfig.Click += ConfigMenuClick;
- PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
+ PluginUtils.AddToContextMenu(_itemPlugInConfig);
Language.LanguageChanged += OnLanguageChanged;
return true;
}
@@ -96,14 +80,14 @@ namespace GreenshotDropboxPlugin {
}
}
- public virtual void Shutdown() {
+ public void Shutdown() {
Log.Debug("Dropbox Plugin shutdown.");
}
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
_config.ShowConfigDialog();
}
@@ -119,7 +103,7 @@ namespace GreenshotDropboxPlugin {
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
try {
string dropboxUrl = null;
- new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("dropbox", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Dropbox", Language.GetString("dropbox", LangKey.communication_wait),
delegate
{
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
diff --git a/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs b/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
index ff72c88e9..10b737886 100644
--- a/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotDropboxPlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -27,8 +26,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Dropbox")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotDropboxPlugin.DropboxPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
index 6ed823c48..1ecb2ef43 100644
--- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
+++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
@@ -32,12 +32,11 @@ namespace ExternalCommand {
///
/// An Plugin to run commands after an image was written
///
+ [Plugin("ExternalCommand", true)]
public class ExternalCommandPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection();
private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection();
- private IGreenshotHost _host;
- private PluginAttribute _myAttributes;
private ToolStripMenuItem _itemPlugInRoot;
public void Dispose() {
@@ -45,24 +44,19 @@ namespace ExternalCommand {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
- if (disposing) {
- if (_itemPlugInRoot != null) {
- _itemPlugInRoot.Dispose();
- _itemPlugInRoot = null;
- }
- }
- }
-
- public IEnumerable Destinations() {
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposing) return;
+ if (_itemPlugInRoot == null) return;
+ _itemPlugInRoot.Dispose();
+ _itemPlugInRoot = null;
+ }
+ private IEnumerable Destinations() {
foreach(string command in ExternalCommandConfig.Commands) {
yield return new ExternalCommandDestination(command);
}
}
- public IEnumerable Processors() {
- yield break;
- }
///
/// Check and eventually fix the command settings
@@ -91,15 +85,14 @@ namespace ExternalCommand {
Log.WarnFormat("Found 'invalid' commandline {0} for command {1}", ExternalCommandConfig.Commandline[command], command);
return false;
}
+ SimpleServiceProvider.Current.AddService(Destinations());
return true;
}
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- Log.DebugFormat("Initialize called of {0}", myAttributes.Name);
+ public virtual bool Initialize() {
+ Log.DebugFormat("Initialize called");
List commandsToDelete = new List();
// Check configuration
@@ -114,16 +107,12 @@ namespace ExternalCommand {
ExternalCommandConfig.Delete(command);
}
- _host = pluginHost;
- _myAttributes = myAttributes;
-
-
- _itemPlugInRoot = new ToolStripMenuItem {Tag = _host};
+ _itemPlugInRoot = new ToolStripMenuItem();
+ _itemPlugInRoot.Click += ConfigMenuClick;
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
OnLanguageChanged(this, null);
- _itemPlugInRoot.Click += ConfigMenuClick;
- PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
+ PluginUtils.AddToContextMenu(_itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged;
CoreConfig.PropertyChanged += OnIconSizeChanged;
return true;
@@ -154,7 +143,7 @@ namespace ExternalCommand {
}
public virtual void Shutdown() {
- Log.Debug("Shutdown of " + _myAttributes.Name);
+ Log.Debug("Shutdown");
}
private void ConfigMenuClick(object sender, EventArgs eventArgs) {
diff --git a/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs b/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5958ed162..000000000
--- a/GreenshotExternalCommandPlugin/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using Greenshot.Plugin;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("ExternalCommand.ExternalCommandPlugin", true)]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
diff --git a/GreenshotFlickrPlugin/FlickrPlugin.cs b/GreenshotFlickrPlugin/FlickrPlugin.cs
index 9211293d8..1a3676332 100644
--- a/GreenshotFlickrPlugin/FlickrPlugin.cs
+++ b/GreenshotFlickrPlugin/FlickrPlugin.cs
@@ -20,7 +20,6 @@
*/
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
@@ -39,8 +38,6 @@ namespace GreenshotFlickrPlugin
public class FlickrPlugin : IGreenshotPlugin {
private static readonly ILog Log = LogManager.GetLogger(typeof(FlickrPlugin));
private static FlickrConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _itemPlugInConfig;
@@ -49,7 +46,7 @@ namespace GreenshotFlickrPlugin
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
+ protected void Dispose(bool disposing) {
if (!disposing) {
return;
}
@@ -60,25 +57,10 @@ namespace GreenshotFlickrPlugin
_itemPlugInConfig = null;
}
- public IEnumerable Destinations() {
- yield return new FlickrDestination(this);
- }
-
-
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute pluginAttribute) {
- _host = pluginHost;
- Attributes = pluginAttribute;
-
-
+ public bool Initialize() {
// Register configuration (don't need the configuration itself)
_config = IniConfig.GetIniSection();
_resources = new ComponentResourceManager(typeof(FlickrPlugin));
@@ -86,12 +68,11 @@ namespace GreenshotFlickrPlugin
_itemPlugInConfig = new ToolStripMenuItem
{
Text = Language.GetString("flickr", LangKey.Configure),
- Tag = _host,
Image = (Image) _resources.GetObject("flickr")
};
_itemPlugInConfig.Click += ConfigMenuClick;
-
- PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
+ SimpleServiceProvider.Current.AddService(new FlickrDestination(this));
+ PluginUtils.AddToContextMenu(_itemPlugInConfig);
Language.LanguageChanged += OnLanguageChanged;
return true;
}
@@ -102,14 +83,14 @@ namespace GreenshotFlickrPlugin
}
}
- public virtual void Shutdown() {
+ public void Shutdown() {
Log.Debug("Flickr Plugin shutdown.");
}
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
_config.ShowConfigDialog();
}
@@ -122,7 +103,7 @@ namespace GreenshotFlickrPlugin
uploadUrl = null;
try {
string flickrUrl = null;
- new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("flickr", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Flickr", Language.GetString("flickr", LangKey.communication_wait),
delegate {
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
flickrUrl = FlickrUtils.UploadToFlickr(surface, outputSettings, captureDetails.Title, filename);
diff --git a/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs b/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
index 5cbf45777..6b06e2aa5 100644
--- a/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotFlickrPlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -27,8 +26,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Flickr")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotFlickrPlugin.FlickrPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotImgurPlugin/Forms/ImgurHistory.cs b/GreenshotImgurPlugin/Forms/ImgurHistory.cs
index 5a697c8a1..34fb72fb1 100644
--- a/GreenshotImgurPlugin/Forms/ImgurHistory.cs
+++ b/GreenshotImgurPlugin/Forms/ImgurHistory.cs
@@ -146,7 +146,7 @@ namespace GreenshotImgurPlugin {
// Should fix Bug #3378699
pictureBox1.Image = pictureBox1.ErrorImage;
try {
- new PleaseWaitForm().ShowAndWait(ImgurPlugin.Attributes.Name, Language.GetString("imgur", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Imgur", Language.GetString("imgur", LangKey.communication_wait),
delegate {
ImgurUtils.DeleteImgurImage(imgurInfo);
}
diff --git a/GreenshotImgurPlugin/ImgurPlugin.cs b/GreenshotImgurPlugin/ImgurPlugin.cs
index a6c5dba4a..fd397ad6b 100644
--- a/GreenshotImgurPlugin/ImgurPlugin.cs
+++ b/GreenshotImgurPlugin/ImgurPlugin.cs
@@ -33,11 +33,10 @@ namespace GreenshotImgurPlugin {
///
/// This is the ImgurPlugin code
///
+ [Plugin("Imgur", true)]
public class ImgurPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ImgurPlugin));
private static ImgurConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _historyMenuItem;
private ToolStripMenuItem _itemPlugInConfig;
@@ -60,24 +59,15 @@ namespace GreenshotImgurPlugin {
}
}
- public IEnumerable Destinations() {
+ private IEnumerable Destinations() {
yield return new ImgurDestination(this);
}
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
- public bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- _host = pluginHost;
- Attributes = myAttributes;
-
+ public bool Initialize() {
// Get configuration
_config = IniConfig.GetIniSection();
_resources = new ComponentResourceManager(typeof(ImgurPlugin));
@@ -87,25 +77,21 @@ namespace GreenshotImgurPlugin {
Image = (Image) _resources.GetObject("Imgur")
};
- _historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history))
- {
- Tag = _host
- };
+ // Provide the IDestination
+ SimpleServiceProvider.Current.AddService(Destinations());
+ _historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.history));
_historyMenuItem.Click += delegate {
ImgurHistory.ShowHistory();
};
itemPlugInRoot.DropDownItems.Add(_historyMenuItem);
- _itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure))
- {
- Tag = _host
- };
+ _itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure));
_itemPlugInConfig.Click += delegate {
_config.ShowConfigDialog();
};
itemPlugInRoot.DropDownItems.Add(_itemPlugInConfig);
- PluginUtils.AddToContextMenu(_host, itemPlugInRoot);
+ PluginUtils.AddToContextMenu(itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged;
// Enable history if there are items available
@@ -129,7 +115,8 @@ namespace GreenshotImgurPlugin {
}
try
{
- _host.GreenshotForm.BeginInvoke((MethodInvoker)delegate
+ var form = SimpleServiceProvider.Current.GetInstance
();
+ form.BeginInvoke((MethodInvoker)delegate
{
var historyMenuItem = _historyMenuItem;
if (historyMenuItem == null)
diff --git a/GreenshotImgurPlugin/Properties/AssemblyInfo.cs b/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
index b9422af90..19a2e1176 100644
--- a/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotImgurPlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -27,8 +26,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Imgur")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotImgurPlugin.ImgurPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs
index 804491415..853b75e52 100644
--- a/GreenshotJiraPlugin/JiraConnector.cs
+++ b/GreenshotJiraPlugin/JiraConnector.cs
@@ -55,8 +55,9 @@ namespace GreenshotJiraPlugin {
CoreConfig.PropertyChanged += (sender, args) =>
{
if (args.PropertyName == nameof(CoreConfig.IconSize))
- {
- JiraPlugin.Instance.JiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.ScaledIconSize.Width, Height = CoreConfig.ScaledIconSize.Height });
+ {
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
+ jiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.ScaledIconSize.Width, Height = CoreConfig.ScaledIconSize.Height });
}
};
diff --git a/GreenshotJiraPlugin/JiraDestination.cs b/GreenshotJiraPlugin/JiraDestination.cs
index 642dfdff6..ebd2c2910 100644
--- a/GreenshotJiraPlugin/JiraDestination.cs
+++ b/GreenshotJiraPlugin/JiraDestination.cs
@@ -40,16 +40,10 @@ namespace GreenshotJiraPlugin {
public class JiraDestination : AbstractDestination {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraDestination));
private static readonly JiraConfiguration Config = IniConfig.GetIniSection();
- private readonly JiraPlugin _jiraPlugin;
private readonly Issue _jiraIssue;
- public JiraDestination(JiraPlugin jiraPlugin) {
- _jiraPlugin = jiraPlugin;
- }
-
- public JiraDestination(JiraPlugin jiraPlugin, Issue jiraIssue) {
- _jiraPlugin = jiraPlugin;
- _jiraIssue = jiraIssue;
+ public JiraDestination(Issue jiraIssue = null) {
+ _jiraIssue = jiraIssue;
}
public override string Designation => "Jira";
@@ -73,7 +67,7 @@ namespace GreenshotJiraPlugin {
get
{
Image displayIcon = null;
- var jiraConnector = JiraPlugin.Instance.CurrentJiraConnector;
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
if (jiraConnector != null)
{
if (_jiraIssue != null)
@@ -104,13 +98,13 @@ namespace GreenshotJiraPlugin {
public override IEnumerable DynamicDestinations()
{
- var jiraConnector = JiraPlugin.Instance.CurrentJiraConnector;
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
if (jiraConnector == null || !jiraConnector.IsLoggedIn) {
yield break;
}
foreach(var jiraDetails in jiraConnector.Monitor.RecentJiras)
{
- yield return new JiraDestination(_jiraPlugin,jiraDetails.JiraIssue);
+ yield return new JiraDestination(jiraDetails.JiraIssue);
}
}
@@ -118,6 +112,7 @@ namespace GreenshotJiraPlugin {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string filename = Path.GetFileName(FilenameHelper.GetFilename(Config.UploadFormat, captureDetails));
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(Config.UploadFormat, Config.UploadJpegQuality, Config.UploadReduceColors);
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
if (_jiraIssue != null) {
try {
// Run upload in the background
@@ -125,8 +120,8 @@ namespace GreenshotJiraPlugin {
async () =>
{
var surfaceContainer = new SurfaceContainer(surfaceToUpload, outputSettings, filename);
- await _jiraPlugin.JiraConnector.AttachAsync(_jiraIssue.Key, surfaceContainer);
- surfaceToUpload.UploadUrl = _jiraPlugin.JiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key).AbsoluteUri;
+ await jiraConnector.AttachAsync(_jiraIssue.Key, surfaceContainer);
+ surfaceToUpload.UploadUrl = jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key).AbsoluteUri;
}
);
Log.DebugFormat("Uploaded to Jira {0}", _jiraIssue.Key);
@@ -136,12 +131,12 @@ namespace GreenshotJiraPlugin {
MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
}
} else {
- var jiraForm = new JiraForm(_jiraPlugin.JiraConnector);
+ var jiraForm = new JiraForm(jiraConnector);
jiraForm.SetFilename(filename);
var dialogResult = jiraForm.ShowDialog();
if (dialogResult == DialogResult.OK) {
try {
- surfaceToUpload.UploadUrl = _jiraPlugin.JiraConnector.JiraBaseUri.AppendSegments("browse", jiraForm.GetJiraIssue().Key).AbsoluteUri;
+ surfaceToUpload.UploadUrl = jiraConnector.JiraBaseUri.AppendSegments("browse", jiraForm.GetJiraIssue().Key).AbsoluteUri;
// Run upload in the background
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
async () =>
diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs
index 1b18c0ef4..7127e6cbe 100644
--- a/GreenshotJiraPlugin/JiraPlugin.cs
+++ b/GreenshotJiraPlugin/JiraPlugin.cs
@@ -33,11 +33,10 @@ namespace GreenshotJiraPlugin {
///
/// This is the JiraPlugin base code
///
+ [Plugin("Jira", true)]
public class JiraPlugin : IGreenshotPlugin {
private static readonly ILog Log = LogManager.GetLogger(typeof(JiraPlugin));
private JiraConfiguration _config;
- private static JiraPlugin _instance;
- private JiraConnector _jiraConnector;
public void Dispose() {
Dispose(true);
@@ -45,58 +44,27 @@ namespace GreenshotJiraPlugin {
}
protected void Dispose(bool disposing) {
- if (disposing) {
- if (JiraConnector != null) {
- JiraConnector.Dispose();
- JiraConnector = null;
- }
+ if (disposing)
+ {
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
+ jiraConnector?.Dispose();
}
}
- public static JiraPlugin Instance => _instance;
-
- public JiraPlugin() {
- _instance = this;
- }
-
- public IEnumerable Destinations() {
- yield return new JiraDestination(this);
- }
-
- public IEnumerable Processors() {
- yield break;
- }
-
- //Needed for a fail-fast
- public JiraConnector CurrentJiraConnector => JiraConnector;
-
- public JiraConnector JiraConnector
- {
- get
- {
- lock (_instance)
- {
- if (_jiraConnector == null)
- {
- JiraConnector = new JiraConnector();
- }
- }
- return _jiraConnector;
- }
- private set { _jiraConnector = value; }
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
- public bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
+ public bool Initialize() {
// Register configuration (don't need the configuration itself)
_config = IniConfig.GetIniSection();
- // Make sure the loggin is enable for the corect level.
+ // Provide the JiraConnector
+ SimpleServiceProvider.Current.AddService(new JiraConnector());
+ // Provide the IDestination
+ SimpleServiceProvider.Current.AddService(new JiraDestination());
+
+ // Make sure the log is enabled for the correct level.
if (Log.IsDebugEnabled)
{
LogSettings.RegisterDefaultLogger(LogLevels.Verbose);
@@ -142,7 +110,8 @@ namespace GreenshotJiraPlugin {
public void Shutdown() {
Log.Debug("Jira Plugin shutdown.");
- JiraConnector?.Logout();
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
+ jiraConnector?.Logout();
}
///
@@ -152,12 +121,13 @@ namespace GreenshotJiraPlugin {
string url = _config.Url;
if (ShowConfigDialog()) {
// check for re-login
- if (JiraConnector != null && JiraConnector.IsLoggedIn && !string.IsNullOrEmpty(url)) {
+ var jiraConnector = SimpleServiceProvider.Current.GetInstance();
+ if (jiraConnector != null && jiraConnector.IsLoggedIn && !string.IsNullOrEmpty(url)) {
if (!url.Equals(_config.Url)) {
- JiraConnector.Logout();
+ jiraConnector.Logout();
Task.Run(async () =>
{
- await JiraConnector.LoginAsync();
+ await jiraConnector.LoginAsync();
});
}
}
diff --git a/GreenshotPlugin/Core/Func.cs b/GreenshotOCRPlugin/ModiLanguage.cs
similarity index 56%
rename from GreenshotPlugin/Core/Func.cs
rename to GreenshotOCRPlugin/ModiLanguage.cs
index e76abe766..b707d3f69 100644
--- a/GreenshotPlugin/Core/Func.cs
+++ b/GreenshotOCRPlugin/ModiLanguage.cs
@@ -18,12 +18,33 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
-namespace GreenshotPlugin.Core
+namespace GreenshotOCR
{
- public delegate TResult Func();
- public delegate TResult Func(T arg);
- public delegate TResult Func(T1 arg1, T2 arg2);
- public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3);
- public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-}
+ ///
+ /// Needed for the drop down, available languages for OCR
+ ///
+ public enum ModiLanguage {
+ CHINESE_SIMPLIFIED = 2052,
+ CHINESE_TRADITIONAL = 1028,
+ CZECH = 5,
+ DANISH = 6,
+ DUTCH = 19,
+ ENGLISH = 9,
+ FINNISH = 11,
+ FRENCH = 12,
+ GERMAN = 7,
+ GREEK = 8,
+ HUNGARIAN = 14,
+ ITALIAN = 16,
+ JAPANESE = 17,
+ KOREAN = 18,
+ NORWEGIAN = 20,
+ POLISH = 21,
+ PORTUGUESE = 22,
+ RUSSIAN = 25,
+ SPANISH = 10,
+ SWEDISH = 29,
+ TURKISH = 31,
+ SYSDEFAULT = 2048
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOCRPlugin/OCRPlugin.cs b/GreenshotOCRPlugin/OCRPlugin.cs
index 45902295c..107be1da7 100644
--- a/GreenshotOCRPlugin/OCRPlugin.cs
+++ b/GreenshotOCRPlugin/OCRPlugin.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
@@ -31,39 +30,14 @@ using GreenshotPlugin.Effects;
//using Microsoft.Win32;
namespace GreenshotOCR {
- // Needed for the drop down, available languages for OCR
- public enum ModiLanguage {
- CHINESE_SIMPLIFIED = 2052,
- CHINESE_TRADITIONAL = 1028,
- CZECH = 5,
- DANISH = 6,
- DUTCH = 19,
- ENGLISH = 9,
- FINNISH = 11,
- FRENCH = 12,
- GERMAN = 7,
- GREEK = 8,
- HUNGARIAN = 14,
- ITALIAN = 16,
- JAPANESE = 17,
- KOREAN = 18,
- NORWEGIAN = 20,
- POLISH = 21,
- PORTUGUESE = 22,
- RUSSIAN = 25,
- SPANISH = 10,
- SWEDISH = 29,
- TURKISH = 31,
- SYSDEFAULT = 2048
- }
///
/// OCR Plugin Greenshot
///
+ [Plugin("Ocr", true)]
public class OcrPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(OcrPlugin));
private string _ocrCommand;
- private static OCRConfiguration config;
- private PluginAttribute _myAttributes;
+ private static OCRConfiguration _config;
private ToolStripMenuItem _ocrMenuItem = new ToolStripMenuItem();
public void Dispose() {
@@ -80,24 +54,14 @@ namespace GreenshotOCR {
}
}
- public IEnumerable Destinations() {
- yield return new OCRDestination(this);
- }
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
- public virtual bool Initialize(IGreenshotHost greenshotHost, PluginAttribute myAttributes) {
- Log.Debug("Initialize called of " + myAttributes.Name);
- _myAttributes = myAttributes;
+ public bool Initialize() {
+ Log.Debug("Initialize called");
- var ocrDirectory = Path.GetDirectoryName(myAttributes.DllFile);
+ var ocrDirectory = Path.GetDirectoryName(GetType().Assembly.Location);
if (ocrDirectory == null)
{
return false;
@@ -108,11 +72,13 @@ namespace GreenshotOCR {
Log.Warn("No MODI found!");
return false;
}
+ // Provide the IDestination
+ SimpleServiceProvider.Current.AddService(new OCRDestination(this));
// Load configuration
- config = IniConfig.GetIniSection();
+ _config = IniConfig.GetIniSection();
- if (config.Language != null) {
- config.Language = config.Language.Replace("miLANG_","").Replace("_"," ");
+ if (_config.Language != null) {
+ _config.Language = _config.Language.Replace("miLANG_","").Replace("_"," ");
}
return true;
}
@@ -121,18 +87,18 @@ namespace GreenshotOCR {
/// Implementation of the IGreenshotPlugin.Shutdown
///
public void Shutdown() {
- Log.Debug("Shutdown of " + _myAttributes.Name);
+ Log.Debug("Shutdown");
}
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
if (!HasModi()) {
MessageBox.Show("Sorry, is seems that Microsoft Office Document Imaging (MODI) is not installed, therefor the OCR Plugin cannot work.");
return;
}
- SettingsForm settingsForm = new SettingsForm(Enum.GetNames(typeof(ModiLanguage)), config);
+ SettingsForm settingsForm = new SettingsForm(Enum.GetNames(typeof(ModiLanguage)), _config);
DialogResult result = settingsForm.ShowDialog();
if (result == DialogResult.OK) {
// "Re"set hotkeys
@@ -177,7 +143,7 @@ namespace GreenshotOCR {
string text = "";
try {
- ProcessStartInfo processStartInfo = new ProcessStartInfo(_ocrCommand, "\"" + filePath + "\" " + config.Language + " " + config.Orientimage + " " + config.StraightenImage)
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(_ocrCommand, "\"" + filePath + "\" " + _config.Language + " " + _config.Orientimage + " " + _config.StraightenImage)
{
CreateNoWindow = true,
RedirectStandardOutput = true,
diff --git a/GreenshotOCRPlugin/Properties/AssemblyInfo.cs b/GreenshotOCRPlugin/Properties/AssemblyInfo.cs
deleted file mode 100644
index 242541957..000000000
--- a/GreenshotOCRPlugin/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using Greenshot.Plugin;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotOCR.OcrPlugin", true)]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
diff --git a/GreenshotOfficePlugin/OfficePlugin.cs b/GreenshotOfficePlugin/OfficePlugin.cs
index 1db639e85..2b1228cb9 100644
--- a/GreenshotOfficePlugin/OfficePlugin.cs
+++ b/GreenshotOfficePlugin/OfficePlugin.cs
@@ -21,12 +21,15 @@
using System;
using System.Collections.Generic;
using Greenshot.Plugin;
+using GreenshotPlugin.Core;
namespace GreenshotOfficePlugin {
///
/// This is the OfficePlugin base code
///
- public class OfficePlugin : IGreenshotPlugin {
+ [Plugin("Office", false)]
+ public class OfficePlugin : IGreenshotPlugin
+ {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OfficePlugin));
public void Dispose() {
@@ -38,7 +41,7 @@ namespace GreenshotOfficePlugin {
// Do nothing
}
- public IEnumerable Destinations() {
+ private IEnumerable Destinations() {
IDestination destination;
try {
destination = new ExcelDestination();
@@ -86,21 +89,17 @@ namespace GreenshotOfficePlugin {
}
}
- public IEnumerable Processors() {
- yield break;
- }
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
+ public bool Initialize() {
+ SimpleServiceProvider.Current.AddService(Destinations());
return true;
}
- public virtual void Shutdown() {
+ public void Shutdown() {
LOG.Debug("Office Plugin shutdown.");
}
diff --git a/GreenshotOfficePlugin/Properties/AssemblyInfo.cs b/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
index cd86fb7ca..50c27e0ec 100644
--- a/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotOfficePlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -27,8 +26,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to export images to Office applications")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotOfficePlugin.OfficePlugin", false)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs b/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs
index 9b3f8aa4e..f519f905f 100644
--- a/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs
+++ b/GreenshotPhotobucketPlugin/PhotobucketConfiguration.cs
@@ -58,7 +58,7 @@ namespace GreenshotPhotobucketPlugin {
public bool ShowConfigDialog() {
SettingsForm settingsForm = null;
- new PleaseWaitForm().ShowAndWait(PhotobucketPlugin.Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Photobucket", Language.GetString("photobucket", LangKey.communication_wait),
delegate {
settingsForm = new SettingsForm();
}
diff --git a/GreenshotPhotobucketPlugin/PhotobucketDestination.cs b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
index 9f897db30..4687a7aaa 100644
--- a/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
+++ b/GreenshotPhotobucketPlugin/PhotobucketDestination.cs
@@ -37,7 +37,7 @@ namespace GreenshotPhotobucketPlugin {
///
///
/// path to the album, null for default
- public PhotobucketDestination(PhotobucketPlugin plugin, string albumPath) {
+ public PhotobucketDestination(PhotobucketPlugin plugin, string albumPath = null) {
_plugin = plugin;
_albumPath = albumPath;
}
diff --git a/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
index ee7483ef4..7c2be8feb 100644
--- a/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
+++ b/GreenshotPhotobucketPlugin/PhotobucketPlugin.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
@@ -33,11 +32,10 @@ namespace GreenshotPhotobucketPlugin {
///
/// This is the GreenshotPhotobucketPlugin base code
///
+ [Plugin("Photobucket", true)]
public class PhotobucketPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(PhotobucketPlugin));
private static PhotobucketConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _itemPlugInConfig;
@@ -46,32 +44,20 @@ namespace GreenshotPhotobucketPlugin {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
- if (disposing) {
- if (_itemPlugInConfig != null) {
- _itemPlugInConfig.Dispose();
- _itemPlugInConfig = null;
- }
- }
- }
-
- public IEnumerable Destinations() {
- yield return new PhotobucketDestination(this, null);
- }
-
- public IEnumerable Processors() {
- yield break;
- }
+ protected void Dispose(bool disposing)
+ {
+ if (!disposing) return;
+ if (_itemPlugInConfig == null) return;
+ _itemPlugInConfig.Dispose();
+ _itemPlugInConfig = null;
+ }
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
/// true if plugin is initialized, false if not (doesn't show)
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- _host = pluginHost;
- Attributes = myAttributes;
+ public bool Initialize() {
+ SimpleServiceProvider.Current.AddService(new PhotobucketDestination(this));
// Get configuration
_config = IniConfig.GetIniSection();
@@ -79,14 +65,13 @@ namespace GreenshotPhotobucketPlugin {
_itemPlugInConfig = new ToolStripMenuItem(Language.GetString("photobucket", LangKey.configure))
{
- Tag = _host,
Image = (Image)_resources.GetObject("Photobucket")
};
_itemPlugInConfig.Click += delegate {
_config.ShowConfigDialog();
};
- PluginUtils.AddToContextMenu(_host, _itemPlugInConfig);
+ PluginUtils.AddToContextMenu(_itemPlugInConfig);
Language.LanguageChanged += OnLanguageChanged;
return true;
}
@@ -97,7 +82,7 @@ namespace GreenshotPhotobucketPlugin {
}
}
- public virtual void Shutdown() {
+ public void Shutdown() {
Log.Debug("Photobucket Plugin shutdown.");
Language.LanguageChanged -= OnLanguageChanged;
}
@@ -105,7 +90,7 @@ namespace GreenshotPhotobucketPlugin {
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
_config.ShowConfigDialog();
}
@@ -124,7 +109,7 @@ namespace GreenshotPhotobucketPlugin {
PhotobucketInfo photobucketInfo = null;
// Run upload in the background
- new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Photobucket", Language.GetString("photobucket", LangKey.communication_wait),
delegate {
photobucketInfo = PhotobucketUtils.UploadToPhotobucket(surfaceToUpload, outputSettings, albumPath, captureDetails.Title, filename);
}
diff --git a/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
index 9f85c8546..9aa4884a4 100644
--- a/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotPhotobucketPlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -28,8 +27,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Photobucket")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotPhotobucketPlugin.PhotobucketPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotPicasaPlugin/PicasaPlugin.cs b/GreenshotPicasaPlugin/PicasaPlugin.cs
index 76bd80250..ea20eb070 100644
--- a/GreenshotPicasaPlugin/PicasaPlugin.cs
+++ b/GreenshotPicasaPlugin/PicasaPlugin.cs
@@ -18,7 +18,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
@@ -32,11 +31,10 @@ namespace GreenshotPicasaPlugin {
///
/// This is the Picasa base code
///
+ [Plugin("Picasa", true)]
public class PicasaPlugin : IGreenshotPlugin {
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(PicasaPlugin));
private static PicasaConfiguration _config;
- public static PluginAttribute Attributes;
- private IGreenshotHost _host;
private ComponentResourceManager _resources;
private ToolStripMenuItem _itemPlugInRoot;
@@ -45,7 +43,7 @@ namespace GreenshotPicasaPlugin {
GC.SuppressFinalize(this);
}
- protected virtual void Dispose(bool disposing) {
+ protected void Dispose(bool disposing) {
if (disposing) {
if (_itemPlugInRoot != null) {
_itemPlugInRoot.Dispose();
@@ -54,23 +52,11 @@ namespace GreenshotPicasaPlugin {
}
}
- public IEnumerable Destinations() {
- yield return new PicasaDestination(this);
- }
-
-
- public IEnumerable Processors() {
- yield break;
- }
-
///
/// Implementation of the IGreenshotPlugin.Initialize
///
- /// Use the IGreenshotPluginHost interface to register events
- /// My own attributes
- public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
- _host = pluginHost;
- Attributes = myAttributes;
+ public bool Initialize() {
+ SimpleServiceProvider.Current.AddService(new PicasaDestination(this));
// Get configuration
_config = IniConfig.GetIniSection();
@@ -79,11 +65,10 @@ namespace GreenshotPicasaPlugin {
_itemPlugInRoot = new ToolStripMenuItem
{
Text = Language.GetString("picasa", LangKey.Configure),
- Tag = _host,
Image = (Image) _resources.GetObject("Picasa")
};
_itemPlugInRoot.Click += ConfigMenuClick;
- PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
+ PluginUtils.AddToContextMenu(_itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged;
return true;
}
@@ -94,7 +79,7 @@ namespace GreenshotPicasaPlugin {
}
}
- public virtual void Shutdown() {
+ public void Shutdown() {
Log.Debug("Picasa Plugin shutdown.");
Language.LanguageChanged -= OnLanguageChanged;
//host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened);
@@ -103,7 +88,7 @@ namespace GreenshotPicasaPlugin {
///
/// Implementation of the IPlugin.Configure
///
- public virtual void Configure() {
+ public void Configure() {
_config.ShowConfigDialog();
}
@@ -115,7 +100,7 @@ namespace GreenshotPicasaPlugin {
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality);
try {
string url = null;
- new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
+ new PleaseWaitForm().ShowAndWait("Picasa", Language.GetString("picasa", LangKey.communication_wait),
delegate
{
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
diff --git a/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs b/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
index 481007a5c..35cc458c3 100644
--- a/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
+++ b/GreenshotPicasaPlugin/Properties/AssemblyInfo.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -27,8 +26,6 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("A plugin to upload images to Picasa")]
-// The PluginAttribute describes the "entryType" and if the plugin is configurable
-[assembly: Plugin("GreenshotPicasaPlugin.PicasaPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
diff --git a/GreenshotPlugin/Core/AbstractDestination.cs b/GreenshotPlugin/Core/AbstractDestination.cs
index 0a0220642..33aff20c1 100644
--- a/GreenshotPlugin/Core/AbstractDestination.cs
+++ b/GreenshotPlugin/Core/AbstractDestination.cs
@@ -260,7 +260,7 @@ namespace GreenshotPlugin.Core {
location.Offset(-40, -10);
}
// This prevents the problem that the context menu shows in the task-bar
- User32.SetForegroundWindow(PluginUtils.Host.NotifyIcon.ContextMenuStrip.Handle);
+ User32.SetForegroundWindow(SimpleServiceProvider.Current.GetInstance().ContextMenuStrip.Handle);
menu.Show(location);
menu.Focus();
diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs
index a17f75d3d..3359048a9 100644
--- a/GreenshotPlugin/Core/ImageHelper.cs
+++ b/GreenshotPlugin/Core/ImageHelper.cs
@@ -52,16 +52,11 @@ namespace GreenshotPlugin.Core {
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection();
private const int ExifOrientationId = 0x0112;
- ///
- /// This is a factory method to create a surface, set from the Greenshot main project
- ///
- public static Func SurfaceFactory { get; set; }
-
- static ImageHelper()
+ static ImageHelper()
{
StreamConverters["greenshot"] = (stream, s) =>
{
- var surface = SurfaceFactory();
+ var surface = SimpleServiceProvider.Current.GetInstance>().Invoke();
return surface.GetImageForExport();
};
diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs
index 4edb453c2..781585076 100644
--- a/GreenshotPlugin/Core/PluginUtils.cs
+++ b/GreenshotPlugin/Core/PluginUtils.cs
@@ -45,14 +45,6 @@ namespace GreenshotPlugin.Core {
CoreConfig.PropertyChanged += OnIconSizeChanged;
}
- ///
- /// Simple global property to get the Greenshot host
- ///
- public static IGreenshotHost Host {
- get;
- set;
- }
-
///
/// Clear icon cache
///
@@ -220,11 +212,10 @@ namespace GreenshotPlugin.Core {
///
/// Helper method to add a plugin MenuItem to the Greenshot context menu
///
- /// IGreenshotHost
/// ToolStripMenuItem
- public static void AddToContextMenu(IGreenshotHost host, ToolStripMenuItem item) {
- // Here we can hang ourselves to the main context menu!
- ContextMenuStrip contextMenu = host.MainMenu;
+ public static void AddToContextMenu(ToolStripMenuItem item) {
+ // Here we can hang ourselves to the main context menu!
+ var contextMenu = SimpleServiceProvider.Current.GetInstance();
bool addedItem = false;
// Try to find a separator, so we insert ourselves after it
diff --git a/GreenshotPlugin/Core/SimpleServiceProvider.cs b/GreenshotPlugin/Core/SimpleServiceProvider.cs
new file mode 100644
index 000000000..5482f107a
--- /dev/null
+++ b/GreenshotPlugin/Core/SimpleServiceProvider.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using GreenshotPlugin.Interfaces;
+
+namespace GreenshotPlugin.Core
+{
+ ///
+ /// A really cheap and simple DI system
+ ///
+ public class SimpleServiceProvider : IServiceLocator
+ {
+ private readonly Dictionary> _services = new Dictionary>();
+
+ public static IServiceLocator Current { get; } = new SimpleServiceProvider();
+
+ public IEnumerable GetAllInstances()
+ {
+ var typeOfService = typeof(TService);
+ if (!_services.TryGetValue(typeOfService, out var results))
+ {
+ yield break;
+ }
+ foreach (TService result in results)
+ {
+ yield return result;
+ }
+ }
+
+ public TService GetInstance()
+ {
+ return GetAllInstances().SingleOrDefault();
+ }
+
+ public void AddService(IEnumerable services)
+ {
+ var serviceType = typeof(TService);
+ if (!_services.TryGetValue(serviceType, out var currentServices))
+ {
+ currentServices = new List