diff --git a/DepartmentPortal/Common/DesktopTools/BusinessLogics/DesktopLoader.cs b/DepartmentPortal/Common/DesktopTools/BusinessLogics/DesktopLoader.cs new file mode 100644 index 0000000..cdf05ae --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BusinessLogics/DesktopLoader.cs @@ -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\\"; + + /// + /// Загрузка всех классов-реализаций IWindowDesktopExtension + /// + /// + public static List GetWindowDesktopExtensions() + { + var list = new List(); + if (Directory.Exists(_pathToWindowDestopExt)) + { + var files = Directory.GetFiles(_pathToWindowDestopExt, "*.dll", SearchOption.AllDirectories); + var loadedFiles = new List(); + 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; + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/ModuleTools/Interfaces/IWindowDesktopExtension.cs b/DepartmentPortal/Common/DesktopTools/Interfaces/IWindowDesktopExtension.cs similarity index 89% rename from DepartmentPortal/Common/ModuleTools/Interfaces/IWindowDesktopExtension.cs rename to DepartmentPortal/Common/DesktopTools/Interfaces/IWindowDesktopExtension.cs index 5fdbb01..4a65857 100644 --- a/DepartmentPortal/Common/ModuleTools/Interfaces/IWindowDesktopExtension.cs +++ b/DepartmentPortal/Common/DesktopTools/Interfaces/IWindowDesktopExtension.cs @@ -1,7 +1,7 @@ -using ModuleTools.Models; +using DesktopTools.Models; using System.Collections.Generic; -namespace ModuleTools.Interfaces +namespace DesktopTools.Interfaces { /// /// Интерфейс для регистрации контролов для десктопного приложения diff --git a/DepartmentPortal/Common/ModuleTools/Models/WindowDesktopExtensionControlModel.cs b/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs similarity index 62% rename from DepartmentPortal/Common/ModuleTools/Models/WindowDesktopExtensionControlModel.cs rename to DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs index 1d9e081..051577a 100644 --- a/DepartmentPortal/Common/ModuleTools/Models/WindowDesktopExtensionControlModel.cs +++ b/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs @@ -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 { diff --git a/DepartmentPortal/Common/ModuleTools/BusinessLogics/ServiceProviderLoader.cs b/DepartmentPortal/Common/ModuleTools/BusinessLogics/ServiceProviderLoader.cs index e46e0e8..1eeafc1 100644 --- a/DepartmentPortal/Common/ModuleTools/BusinessLogics/ServiceProviderLoader.cs +++ b/DepartmentPortal/Common/ModuleTools/BusinessLogics/ServiceProviderLoader.cs @@ -12,7 +12,7 @@ namespace ModuleTools.BusinessLogics /// /// Загрузчик данных /// - 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; } - /// - /// Загрузка всех классов-реализаций IWindowDesktopExtension - /// - /// - public static List GetWindowDesktopExtensions() - { - var list = new List(); - if (Directory.Exists(_pathToWindowDestopExt)) - { - var files = Directory.GetFiles(_pathToWindowDestopExt, "*.dll", SearchOption.AllDirectories); - var loadedFiles = new List(); - 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; - } - /// /// Получение имени файла /// diff --git a/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs b/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs index 2b8c907..2a10eed 100644 --- a/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs +++ b/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs @@ -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(); _controls = new Dictionary(); - var extensions = ServiceProviderLoader.GetWindowDesktopExtensions(); + var extensions = DesktopLoader.GetWindowDesktopExtensions(); foreach (var extens in extensions) { var list = extens?.GetListControlEntityList()?.OrderBy(x => x.Order).ToList();