aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-13 19:41:19 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-13 19:41:19 +0200
commitee88fc31d9b1b8f4782c7103d91de2d1b11c211b (patch)
treefd988b09e9aea2cd0ccc6a6174d61d4e7811def7 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules
parent39d2d7ff77e3ac949db6d9adde861275401e5e57 (diff)
downloadTango-ee88fc31d9b1b8f4782c7103d91de2d1b11c211b.tar.gz
Tango-ee88fc31d9b1b8f4782c7103d91de2d1b11c211b.zip
Implemented StudioModuleBase.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs27
1 files changed, 23 insertions, 4 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
index e08ee9b08..5951137e3 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
@@ -1,4 +1,5 @@
-using System;
+using GalaSoft.MvvmLight.Ioc;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@@ -8,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Integration.Observables;
+using Tango.Logging;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Authentication;
using Tango.MachineStudio.Common.Modules;
@@ -95,12 +97,19 @@ namespace Tango.MachineStudio.UI.Modules
if (moduleAssembly != null)
{
- foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x)))
+ foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x) && !x.IsAbstract))
{
if (!AllModules.ToList().Exists(x => x.GetType() == moduleType))
{
- var module = Activator.CreateInstance(moduleType) as IStudioModule;
- AllModules.Add(module);
+ try
+ {
+ var module = Activator.CreateInstance(moduleType) as IStudioModule;
+ AllModules.Add(module);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Could not load module " + moduleType.Name);
+ }
}
}
}
@@ -120,5 +129,15 @@ namespace Tango.MachineStudio.UI.Modules
ModulesLoaded?.Invoke(this, new EventArgs());
}
+
+ /// <summary>
+ /// Gets the studio module of type T if loaded.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns></returns>
+ public T GetStudioModule<T>() where T : IStudioModule
+ {
+ return UserModules.OfType<T>().FirstOrDefault();
+ }
}
}