Отказ от DI и добавление фабрик
This commit is contained in:
@@ -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;
|
||||
@@ -59,24 +58,8 @@ public abstract class DragSourceBehaviorBase<TElement> : IDragSource
|
||||
/// </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>
|
||||
/// Получает значение, указывающее, выполняется ли в данный момент операция перетаскивания.
|
||||
@@ -86,13 +69,13 @@ public abstract class DragSourceBehaviorBase<TElement> : IDragSource
|
||||
/// <summary>
|
||||
/// Инициализирует новый экземпляр класса <see cref="DragSourceBehaviorBase{TElement}"/>.
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider">Провайдер сервисов для разрешения зависимостей.</param>
|
||||
/// <param name="dragDropService">Сервис перетаскивания.</param>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// Выбрасывается, когда <paramref name="serviceProvider"/> равен null.
|
||||
/// Выбрасывается, когда <paramref name="dragDropService"/> равен null.
|
||||
/// </exception>
|
||||
protected DragSourceBehaviorBase(IServiceProvider serviceProvider)
|
||||
protected DragSourceBehaviorBase(IDragDropService dragDropService)
|
||||
{
|
||||
ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
|
||||
DragDropService = dragDropService ?? throw new ArgumentNullException(nameof(dragDropService));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user