перенос интерфейсов в desktop проект

This commit is contained in:
kotcheshir73 2021-03-28 19:30:56 +04:00
parent e7a6a41eed
commit f63cbb816d
5 changed files with 53 additions and 42 deletions

View File

@ -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;
}
}
}

View File

@ -1,7 +1,7 @@
using ModuleTools.Models;
using DesktopTools.Models;
using System.Collections.Generic;
namespace ModuleTools.Interfaces
namespace DesktopTools.Interfaces
{
/// <summary>
/// Интерфейс для регистрации контролов для десктопного приложения

View File

@ -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
{

View File

@ -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>

View File

@ -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();