[longomatch] Make the addins manager register services



commit 91bf390cefbe8c25d028814231462bb43173f728
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Apr 14 01:06:44 2015 +0200

    Make the addins manager register services

 LongoMatch.Addins/AddinsManager.cs         |   29 ++++++++++++---------------
 LongoMatch.Addins/LongoMatch.Addins.csproj |    5 +++-
 LongoMatch.Services/CoreServices.cs        |    6 -----
 LongoMatch/Main.cs                         |    1 +
 Makefile.am                                |    2 +-
 build/build.environment.mk                 |    1 +
 pkgconfig/longomatch-addins.pc.in          |    2 +-
 pkgconfig/longomatch-services.pc.in        |    2 +-
 8 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/LongoMatch.Addins/AddinsManager.cs b/LongoMatch.Addins/AddinsManager.cs
index e4d278f..2bc4148 100644
--- a/LongoMatch.Addins/AddinsManager.cs
+++ b/LongoMatch.Addins/AddinsManager.cs
@@ -26,9 +26,9 @@ using LongoMatch.Core.Interfaces.GUI;
 using LongoMatch.Core.Interfaces.Multimedia;
 using LongoMatch.Core.Store;
 using LongoMatch.Core.Store.Templates;
+using LongoMatch.Services;
 using Mono.Addins;
 using Mono.Addins.Description;
-using LongoMatch.Core.Stats;
 
 [assembly:AddinRoot ("LongoMatch", "1.1")]
 namespace LongoMatch.Addins
@@ -149,21 +149,6 @@ namespace LongoMatch.Addins
                        }
                }
 
-               /// <summary>
-               /// Gets all Services exposed by addins through the IServicesPlugin extension point.
-               /// </summary>
-               /// <returns>A List of services provided by addins.</returns>
-               public static List<IService> GetAddinsServices ()
-               {
-                       List<IService> services = new List<IService> ();
-
-                       foreach (IServicesPlugin plugin in AddinManager.GetExtensionObjects<IServicesPlugin> 
()) {
-                               services.AddRange (plugin.Services);
-                       }
-
-                       return services;
-               }
-
                public static void ShutdownMultimediaBackends ()
                {
                        foreach (IMultimediaBackend backend in 
AddinManager.GetExtensionObjects<IMultimediaBackend> ()) {
@@ -181,6 +166,18 @@ namespace LongoMatch.Addins
                        }
                }
 
+               /// <summary>
+               /// Register <see cref="IService"/> exposed by addins through the <see 
cref="IServicesPlugin"/> extension point.
+               /// </summary>
+               public static void LoadServicesAddins ()
+               {
+                       foreach (IServicesPlugin plugin in AddinManager.GetExtensionObjects<IServicesPlugin> 
()) {
+                               foreach (IService service in plugin.Services) {
+                                       CoreServices.RegisterService (service);
+                               }
+                       }
+               }
+
                public static Dictionary<AddinDescription, List<ConfigurablePlugin>> Plugins {
                        get { return pluginsDict; }
                }
diff --git a/LongoMatch.Addins/LongoMatch.Addins.csproj b/LongoMatch.Addins/LongoMatch.Addins.csproj
index 43faecf..f9da6bf 100644
--- a/LongoMatch.Addins/LongoMatch.Addins.csproj
+++ b/LongoMatch.Addins/LongoMatch.Addins.csproj
@@ -46,7 +46,6 @@
   <ItemGroup>
     <Reference Include="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
       <SpecificVersion>False</SpecificVersion>
-      <Package>mono-addins</Package>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
@@ -59,6 +58,10 @@
       <Project>{B70912B2-7ED5-450E-97BD-45A3D45A0358}</Project>
       <Name>LongoMatch.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\LongoMatch.Services\LongoMatch.Services.csproj">
+      <Project>{AA2793F9-3B72-4F34-9B34-2E0C18A8A960}</Project>
+      <Name>LongoMatch.Services</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
diff --git a/LongoMatch.Services/CoreServices.cs b/LongoMatch.Services/CoreServices.cs
index 2f17e9e..195e89d 100644
--- a/LongoMatch.Services/CoreServices.cs
+++ b/LongoMatch.Services/CoreServices.cs
@@ -25,7 +25,6 @@ using LongoMatch.Core.Common;
 using LongoMatch.Core.Interfaces;
 using LongoMatch.Core.Interfaces.GUI;
 using LongoMatch.Core.Interfaces.Multimedia;
-using LongoMatch.Addins;
 using Mono.Unix;
 using LongoMatch.Services.Services;
 
@@ -133,11 +132,6 @@ namespace LongoMatch.Services
                        /* Start the Update Notifier */
                        updatesNotifier = new UpdatesNotifier ();
                        RegisterService (updatesNotifier);
-
-                       /* Register services from addins */
-                       foreach (IService service in AddinsManager.GetAddinsServices ()) {
-                               RegisterService (service);
-                       }
                }
 
                public static void StartServices ()
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index bc18cf7..9fd31b9 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -63,6 +63,7 @@ namespace LongoMatch
                                AddinsManager.LoadExportProjectAddins (Config.GUIToolkit.MainController);
                                AddinsManager.LoadMultimediaBackendsAddins (Config.MultimediaToolkit);
                                AddinsManager.LoadUIBackendsAddins (Config.GUIToolkit);
+                               AddinsManager.LoadServicesAddins ();
                                Config.GUIToolkit.Register<IPlayerView, PlayerView> (0);
 
                                if (!haveCodecs) {
diff --git a/Makefile.am b/Makefile.am
index 6f17adf..adadd5b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,11 +13,11 @@ SUBDIRS = \
        oxyplot \
        LongoMatch.Core \
        LongoMatch.DB \
-       LongoMatch.Addins \
        LongoMatch.Multimedia \
        LongoMatch.Drawing \
        LongoMatch.Drawing.Cairo \
        LongoMatch.Services \
+       LongoMatch.Addins \
        LongoMatch.GUI.Helpers \
        LongoMatch.GUI.Multimedia \
        LongoMatch.GUI \
diff --git a/build/build.environment.mk b/build/build.environment.mk
index e0ba3c9..dfc42c0 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -40,6 +40,7 @@ LINK_LONGOMATCH_SERVICES = -r:$(DIR_BIN)/LongoMatch.Services.dll
 REF_DEP_LONGOMATCH_ADDINS = \
                      $(LINK_MONO_ADDINS) \
                      $(LINK_JSON) \
+                     $(LINK_LONGOMATCH_SERVICES) \
                      $(LINK_LONGOMATCH_CORE)
 
 REF_DEP_LONGOMATCH_PLUGINS = \
diff --git a/pkgconfig/longomatch-addins.pc.in b/pkgconfig/longomatch-addins.pc.in
index 7a96dee..d504c42 100644
--- a/pkgconfig/longomatch-addins.pc.in
+++ b/pkgconfig/longomatch-addins.pc.in
@@ -6,5 +6,5 @@ longomatchdir= libdir@/@PACKAGE@
 Name: LongoMatch.Addins
 Description: LongoMatch addins framework for .NET
 Version: @VERSION@
-Requires: mono-addins longomatch-core
+Requires: mono-addins longomatch-core longomatch-services
 Libs: -r:${longomatchdir}/LongoMatch.Addins.dll
diff --git a/pkgconfig/longomatch-services.pc.in b/pkgconfig/longomatch-services.pc.in
index d807a74..8d9839e 100644
--- a/pkgconfig/longomatch-services.pc.in
+++ b/pkgconfig/longomatch-services.pc.in
@@ -6,5 +6,5 @@ longomatchdir= libdir@/@PACKAGE@
 Name: LongoMatch.Services
 Description: LongoMatch Services framework for .NET
 Version: @VERSION@
-Requires: longomatch-addins longomatch-core longomatch-drawing
+Requires: longomatch-core longomatch-drawing
 Libs: -r:${longomatchdir}/LongoMatch.Services.dll


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]