using System; using System.ComponentModel.Composition; using System.Windows.Media.Imaging; using DTS.Common; using DTS.Common.Interface; using DTS.Common.Utilities.Logging; using DTS.StatusAndProgressBar; using Prism.Ioc; using Prism.Modularity; using StatusAndProgressBar; using Unity; // ReSharper disable UnusedParameter.Local [assembly: StatusAndProgressBarPropertiesName()] [assembly: StatusAndProgressBarPropertiesImage()] namespace StatusAndProgressBar { [Export(typeof(IModule))] [Module(ModuleName = "StatusAndProgressBarProperties")] public class StatusAndProgressBarModule : IModule { /// /// Injected unity container /// private readonly IUnityContainer _unityContainer; /// /// Initializes a new instance of the class. /// /// Obtained reference of the unity container by using dependency injection. public StatusAndProgressBarModule(IUnityContainer unityContainer) { _unityContainer = unityContainer; } public void Initialize() { try { // Register View & View-Model with Unity dependency injection container as a singleton. _unityContainer.RegisterType(); _unityContainer.RegisterType(); _unityContainer.RegisterType(); _unityContainer.RegisterType(); } catch (Exception ex) { APILogger.Log(ex.GetBaseException().ToString()); APILogger.Log(ex.InnerException); APILogger.Log(ex.Message); throw new Exception(ex.GetBaseException().ToString()); } } public void OnInitialized(IContainerProvider containerProvider) { } public void RegisterTypes(IContainerRegistry containerRegistry) { Initialize(); } } /// /// Attribute class contains assembly name /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public class StatusAndProgressBarPropertiesNameAttribute : TextAttribute { private readonly string _assemblyName; public StatusAndProgressBarPropertiesNameAttribute() : this(null) { } public StatusAndProgressBarPropertiesNameAttribute(string s) { _assemblyName = AssemblyNames.Filter.ToString(); } public override string AssemblyName => _assemblyName; public override Type GetAttributeType() { return typeof(TextAttribute); } public override string GetAssemblyName() { return AssemblyName; } } /// /// Attribute class contains assembly image and name - used on the Main screen to display available components /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public class StatusAndProgressBarPropertiesImageAttribute : ImageAttribute { private BitmapImage _img; public StatusAndProgressBarPropertiesImageAttribute() : this(null) { } public override BitmapImage AssemblyImage { get { _img = AssemblyInfo.GetImage(AssemblyNames.StatusAndProgressBar.ToString()); return _img; } } public StatusAndProgressBarPropertiesImageAttribute(string s) { _img = AssemblyInfo.GetImage(AssemblyNames.StatusAndProgressBar.ToString()); } public override Type GetAttributeType() { return typeof(ImageAttribute); } public override BitmapImage GetAssemblyImage() { return AssemblyImage; } public override string GetAssemblyName() { return AssemblyName; } public override eAssemblyRegion GetAssemblyRegion() { return AssemblyRegion; } public override string GetAssemblyGroup() { return AssemblyGroup; } private string _name; public override string AssemblyName { get { _name = AssemblyNames.StatusAndProgressBar.ToString(); return _name; } } private string _group; public override string AssemblyGroup { get { _group = eAssemblyGroups.Viewer.ToString(); return _group; } } private eAssemblyRegion _region; public override eAssemblyRegion AssemblyRegion { get { _region = eAssemblyRegion.StatusAndProgressBarRegion; return _region; } } } }