158 lines
5.8 KiB
C#
158 lines
5.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.ComponentModel.Composition;
|
|||
|
|
using System.Windows.Media.Imaging;
|
|||
|
|
using DTS.Common;
|
|||
|
|
using DTS.Common.Interface;
|
|||
|
|
using DTS.Common.Interface.TestSetups.Imports.TTS;
|
|||
|
|
using DTS.Common.Interface.TestSetups.Imports.TTS.DIChannels;
|
|||
|
|
using DTS.Common.Interface.TestSetups.Imports.TTS.DOChannels;
|
|||
|
|
using Prism.Ioc;
|
|||
|
|
using Prism.Modularity;
|
|||
|
|
using TTSImport;
|
|||
|
|
using Unity;
|
|||
|
|
|
|||
|
|
// ReSharper disable CheckNamespace
|
|||
|
|
// ReSharper disable RedundantAttributeUsageProperty
|
|||
|
|
// ReSharper disable UnusedParameter.Local
|
|||
|
|
|
|||
|
|
[assembly: TTSImportModuleName]
|
|||
|
|
[assembly: TTSImportModuleImageAttribute]
|
|||
|
|
namespace TTSImport
|
|||
|
|
{
|
|||
|
|
[Export(typeof(IModule))]
|
|||
|
|
[Module(ModuleName = "TTSImportModule")]
|
|||
|
|
public class TTSImportModule : IModule
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Injected unity container
|
|||
|
|
/// </summary>
|
|||
|
|
private readonly IUnityContainer _unityContainer;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Initializes a new instance of the <see cref="TTSImportModule"/> class.
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="unityContainer">Obtained reference of the unity container by using dependency injection.</param>
|
|||
|
|
public TTSImportModule(IUnityContainer unityContainer)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
_unityContainer = unityContainer;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Initialize()
|
|||
|
|
{
|
|||
|
|
// Register View & View-Model with Unity dependency injection container as a singleton.
|
|||
|
|
_unityContainer.RegisterType<IHardwareScanView, HardwareScanView>();
|
|||
|
|
_unityContainer.RegisterType<IHardwareScanViewModel, HardwareScanViewModel>();
|
|||
|
|
_unityContainer.RegisterType<IEditFileView, EditFileView>();
|
|||
|
|
_unityContainer.RegisterType<IEditFileViewModel, EditFileViewModel>();
|
|||
|
|
_unityContainer.RegisterType<ISummaryView, SummaryView>();
|
|||
|
|
_unityContainer.RegisterType<ISummaryViewModel, SummaryViewModel>();
|
|||
|
|
_unityContainer.RegisterType<IReadFileView, ReadFileView>();
|
|||
|
|
_unityContainer.RegisterType<IReadFileViewModel, ReadFileViewModel>();
|
|||
|
|
_unityContainer.RegisterType<ILevelTriggerView, LevelTriggerView>();
|
|||
|
|
_unityContainer.RegisterType<ILevelTriggerViewModel, LevelTriggerViewModel>();
|
|||
|
|
_unityContainer.RegisterType<IAnalogChannelsView, AnalogChannelsView>();
|
|||
|
|
_unityContainer.RegisterType<IAnalogChannelsViewModel, AnalogChannelsViewModel>();
|
|||
|
|
_unityContainer.RegisterType<ITOMChannelsView, TOMChannelsView>();
|
|||
|
|
_unityContainer.RegisterType<ITOMChannelsViewModel, TOMChannelsViewModel>();
|
|||
|
|
_unityContainer.RegisterType<IDigitalInputChannelsView, DigitalInputChannelsView>();
|
|||
|
|
_unityContainer.RegisterType<IDigitalInputChannelsViewModel, DigitalInputChannelsViewModel>();
|
|||
|
|
_unityContainer.RegisterType<IDigitalOutputChannelsView, DigitalOutputChannelsView>();
|
|||
|
|
_unityContainer.RegisterType<IDigitalOutputChannelsViewModel, DigitalOutputChannelsViewModel>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnInitialized(IContainerProvider containerProvider)
|
|||
|
|
{
|
|||
|
|
throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
|||
|
|
{
|
|||
|
|
throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Attribute class contains assembly name
|
|||
|
|
/// </summary>
|
|||
|
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
|||
|
|
public class TTSImportModuleNameAttribute : TextAttribute
|
|||
|
|
{
|
|||
|
|
public TTSImportModuleNameAttribute() : this(null) { }
|
|||
|
|
|
|||
|
|
public TTSImportModuleNameAttribute(string s)
|
|||
|
|
{
|
|||
|
|
AssemblyName = AssemblyNames.TTSImport.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override string AssemblyName { get; }
|
|||
|
|
|
|||
|
|
public override Type GetAttributeType()
|
|||
|
|
{
|
|||
|
|
return typeof(TextAttribute);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override string GetAssemblyName()
|
|||
|
|
{
|
|||
|
|
return AssemblyName;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Attribute class contains assembly image and name - used on the Main screen to SummaryModule available components
|
|||
|
|
/// </summary>
|
|||
|
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
|||
|
|
public class TTSImportModuleImageAttribute : ImageAttribute
|
|||
|
|
{
|
|||
|
|
private BitmapImage _img;
|
|||
|
|
|
|||
|
|
public TTSImportModuleImageAttribute() : this(null) { }
|
|||
|
|
public override BitmapImage AssemblyImage
|
|||
|
|
{
|
|||
|
|
get { _img = AssemblyInfo.GetImage(AssemblyNames.TTSImport.ToString()); return _img; }
|
|||
|
|
}
|
|||
|
|
public TTSImportModuleImageAttribute(string s)
|
|||
|
|
{
|
|||
|
|
_img = AssemblyInfo.GetImage(AssemblyNames.TTSImport.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override Type GetAttributeType()
|
|||
|
|
{
|
|||
|
|
return typeof(ImageAttribute);
|
|||
|
|
}
|
|||
|
|
public override BitmapImage GetAssemblyImage()
|
|||
|
|
{
|
|||
|
|
return AssemblyImage;
|
|||
|
|
}
|
|||
|
|
private string _name;
|
|||
|
|
public override string AssemblyName
|
|||
|
|
{
|
|||
|
|
get { _name = AssemblyNames.TTSImport.ToString(); return _name; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override string GetAssemblyName()
|
|||
|
|
{
|
|||
|
|
return AssemblyName;
|
|||
|
|
}
|
|||
|
|
private string _group;
|
|||
|
|
public override string AssemblyGroup
|
|||
|
|
{
|
|||
|
|
get { _group = eAssemblyGroups.Prepare.ToString(); return _group; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override string GetAssemblyGroup()
|
|||
|
|
{
|
|||
|
|
return AssemblyGroup;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private eAssemblyRegion _region;
|
|||
|
|
public override eAssemblyRegion AssemblyRegion
|
|||
|
|
{
|
|||
|
|
get { _region = eAssemblyRegion.TTSImportRegion; return _region; }
|
|||
|
|
}
|
|||
|
|
public override eAssemblyRegion GetAssemblyRegion()
|
|||
|
|
{
|
|||
|
|
return AssemblyRegion;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|