перенос интерфейсов в desktop проект
This commit is contained in:
parent
e7a6a41eed
commit
f63cbb816d
@ -0,0 +1,46 @@
|
||||
using DesktopTools.Interfaces;
|
||||
using ModuleTools.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DesktopTools.BusinessLogics
|
||||
{
|
||||
public static partial class DesktopLoader
|
||||
{
|
||||
private static readonly string _pathToWindowDestopExt = "..\\..\\..\\..\\WindowDestopExtensions\\";
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка всех классов-реализаций IWindowDesktopExtension
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<IWindowDesktopExtension> GetWindowDesktopExtensions()
|
||||
{
|
||||
var list = new List<IWindowDesktopExtension>();
|
||||
if (Directory.Exists(_pathToWindowDestopExt))
|
||||
{
|
||||
var files = Directory.GetFiles(_pathToWindowDestopExt, "*.dll", SearchOption.AllDirectories);
|
||||
var loadedFiles = new List<string>();
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
if (loadedFiles.Contains(file.GetFileName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Assembly asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (t.IsClass && typeof(IWindowDesktopExtension).IsAssignableFrom(t))
|
||||
{
|
||||
list.Add((IWindowDesktopExtension)Activator.CreateInstance(t));
|
||||
}
|
||||
}
|
||||
loadedFiles.Add(file.GetFileName());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using ModuleTools.Models;
|
||||
using DesktopTools.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ModuleTools.Interfaces
|
||||
namespace DesktopTools.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для регистрации контролов для десктопного приложения
|
@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModuleTools.Models
|
||||
namespace DesktopTools.Models
|
||||
{
|
||||
public class WindowDesktopExtensionControlModel
|
||||
{
|
@ -12,7 +12,7 @@ namespace ModuleTools.BusinessLogics
|
||||
/// <summary>
|
||||
/// Загрузчик данных
|
||||
/// </summary>
|
||||
public static class ServiceProviderLoader
|
||||
public static partial class ServiceProviderLoader
|
||||
{
|
||||
private static readonly string _configFileName = "DepartmentPortal.config";
|
||||
|
||||
@ -71,37 +71,6 @@ namespace ModuleTools.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка всех классов-реализаций IWindowDesktopExtension
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<IWindowDesktopExtension> GetWindowDesktopExtensions()
|
||||
{
|
||||
var list = new List<IWindowDesktopExtension>();
|
||||
if (Directory.Exists(_pathToWindowDestopExt))
|
||||
{
|
||||
var files = Directory.GetFiles(_pathToWindowDestopExt, "*.dll", SearchOption.AllDirectories);
|
||||
var loadedFiles = new List<string>();
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
if (loadedFiles.Contains(file.GetFileName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Assembly asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (t.IsClass && typeof(IWindowDesktopExtension).IsAssignableFrom(t))
|
||||
{
|
||||
list.Add((IWindowDesktopExtension)Activator.CreateInstance(t));
|
||||
}
|
||||
}
|
||||
loadedFiles.Add(file.GetFileName());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение имени файла
|
||||
/// </summary>
|
||||
|
@ -1,5 +1,5 @@
|
||||
using DesktopTools.Controls;
|
||||
using ModuleTools.BusinessLogics;
|
||||
using DesktopTools.BusinessLogics;
|
||||
using DesktopTools.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -19,7 +19,7 @@ namespace DepartmentPortalDesctop
|
||||
_baseControls = new Dictionary<Guid, ControlViewEntityList>();
|
||||
_controls = new Dictionary<Guid, ControlViewEntityList>();
|
||||
|
||||
var extensions = ServiceProviderLoader.GetWindowDesktopExtensions();
|
||||
var extensions = DesktopLoader.GetWindowDesktopExtensions();
|
||||
foreach (var extens in extensions)
|
||||
{
|
||||
var list = extens?.GetListControlEntityList()?.OrderBy(x => x.Order).ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user