Отказ от DI и добавление фабрик

This commit is contained in:
2026-01-25 06:01:34 +03:00
parent 6ad7b5dcdb
commit 0e050b452a
7 changed files with 1066 additions and 242 deletions

View File

@@ -2,7 +2,6 @@
using Lattice.Core.DragDrop.Models;
using Lattice.Core.DragDrop.Services;
using Lattice.Core.Geometry;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -76,24 +75,8 @@ public abstract class DropTargetBehaviorBase<TElement> : IDropTarget
/// </summary>
/// <value>
/// Экземпляр <see cref="IDragDropService"/>, используемый для регистрации цели сброса.
/// При первом обращении выполняется получение сервиса из <see cref="ServiceProvider"/>.
/// </value>
protected IDragDropService DragDropService
{
get
{
if (_dragDropService == null)
{
_dragDropService = ServiceProvider.GetRequiredService<IDragDropService>();
}
return _dragDropService;
}
}
/// <summary>
/// Получает провайдер сервисов для разрешения зависимостей.
/// </summary>
protected IServiceProvider ServiceProvider { get; }
protected IDragDropService DragDropService { get; }
/// <summary>
/// Получает текущие границы элемента в экранных координатах.
@@ -116,13 +99,13 @@ public abstract class DropTargetBehaviorBase<TElement> : IDropTarget
/// <summary>
/// Инициализирует новый экземпляр класса <see cref="DropTargetBehaviorBase{TElement}"/>.
/// </summary>
/// <param name="serviceProvider">Провайдер сервисов для разрешения зависимостей.</param>
/// <param name="dragDropService">Сервис перетаскивания.</param>
/// <exception cref="ArgumentNullException">
/// Выбрасывается, когда <paramref name="serviceProvider"/> равен null.
/// Выбрасывается, когда <paramref name="dragDropService"/> равен null.
/// </exception>
protected DropTargetBehaviorBase(IServiceProvider serviceProvider)
protected DropTargetBehaviorBase(IDragDropService dragDropService)
{
ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
DragDropService = dragDropService ?? throw new ArgumentNullException(nameof(dragDropService));
}
/// <summary>