aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs
blob: 827650f591b6bc8f2a95b663aa73e230a244b398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.DI;
using Tango.MachineStudio.Common;

public static class TangoIOCExtensions
{
    /// <summary>
    /// Gets the specified module <see cref="IStudioViewModel"/> view models.
    /// </summary>
    /// <param name="tangoIOC">The Tango IOC.</param>
    /// <param name="module">The module.</param>
    /// <returns></returns>
    public static IEnumerable<IStudioViewModel> GetModuleViewModels(this TangoIOC tangoIOC, IStudioModule module)
    {
        var viewModels = tangoIOC.GetAllInstancesByBase<IStudioViewModel>().Where(x => x != null && x.GetType().BaseType.GetGenericArguments().Length > 0 && x.GetType().BaseType.GetGenericArguments()[0] == module.GetType());
        return viewModels;
    }
}
pan class="p">{ get; set; } public ExceptionWindow() { InitializeComponent(); DataContext = this; } public ExceptionWindow(Exception ex, bool canReport) : this() { Exception = ex.FlattenException(); ResolveCommand = new RelayCommand<ExceptionResolutions>(Resolve); if (!canReport) { btnReport.Visibility = Visibility.Collapsed; } } private void Resolve(ExceptionResolutions resolution) { Resolution = resolution; Close(); } } }