80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using System;
|
|
using DTS.Common.Events;
|
|
using DTS.Common.Interface;
|
|
using Prism.Events;
|
|
using Prism.Ioc;
|
|
using Prism.Modularity;
|
|
using Unity;
|
|
using Unity.Lifetime;
|
|
|
|
// ReSharper disable NotAccessedField.Local
|
|
// ReSharper disable UnusedParameter.Local
|
|
// ReSharper disable ConvertToAutoProperty
|
|
// ReSharper disable RedundantDefaultMemberInitializer
|
|
|
|
namespace DTS.Viewer
|
|
{
|
|
[Module(ModuleName = "Export")]
|
|
public class ExportModule : IExportModule
|
|
{
|
|
/// <summary>
|
|
/// Injected unity container
|
|
/// </summary>
|
|
private readonly IUnityContainer _unityContainer;
|
|
public bool SessionStarted { get; private set; }
|
|
public ExportModule(IUnityContainer unityContainer)
|
|
{
|
|
|
|
_unityContainer = unityContainer;
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
_unityContainer.RegisterType<IExportModule, ExportModule>(new ContainerControlledLifetimeManager());
|
|
}
|
|
|
|
public void StartSession()
|
|
{
|
|
var eventAggregator = _unityContainer.Resolve<IEventAggregator>();
|
|
eventAggregator?.GetEvent<LoadExportModuleEvent>().Publish(new LoadExportModuleArg());
|
|
SessionStarted = true;
|
|
}
|
|
|
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
public void OnInitialized(IContainerProvider containerProvider)
|
|
{
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Attribute class contains assembly name
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
|
public class ExportNameAttribute : TextAttribute
|
|
{
|
|
private readonly string _assemblyName;
|
|
public ExportNameAttribute() : this(null) { }
|
|
|
|
public ExportNameAttribute(string s)
|
|
{
|
|
_assemblyName = "Export";
|
|
}
|
|
|
|
public override string AssemblyName => _assemblyName;
|
|
|
|
public override Type GetAttributeType()
|
|
{
|
|
return typeof(TextAttribute);
|
|
}
|
|
|
|
public override string GetAssemblyName()
|
|
{
|
|
return AssemblyName;
|
|
}
|
|
}
|
|
}
|