From 2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 26 Dec 2017 21:16:15 +0200 Subject: MERGE --- .../Notifications/DefaultNotificationProvider.cs | 16 +++++++++++++++- .../Notifications/MessageBoxWindow.xaml | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 3c245510b..ede66dc19 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -15,6 +15,8 @@ namespace Tango.MachineStudio.UI.Notifications { public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { + private static List viewTypes; + public ObservableCollection TaskItems { get; private set; } public bool HasTaskItems @@ -99,7 +101,19 @@ namespace Tango.MachineStudio.UI.Notifications { String viewName = typeof(VM).Name.Replace("VM", ""); - var view = Activator.CreateInstance(AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Single(x => x.Name == viewName)) as FrameworkElement; + if (viewTypes == null) + { + viewTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).ToList(); + } + + var viewType = viewTypes.SingleOrDefault(x => x.Name == viewName); + + if (viewType == null) + { + throw new NullReferenceException("Could not locate view " + viewName); + } + + var view = Activator.CreateInstance(viewType) as FrameworkElement; DialogWindow dialog = new DialogWindow(); dialog.Owner = Application.Current.MainWindow; dialog.InnerContent = view; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml index 4f3b826fe..a89f8eeca 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml @@ -24,7 +24,7 @@ - -- cgit v1.3.1