From 0b797bd08b872b733b2b8a8565d0c71fce7027c5 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 20 Oct 2024 15:11:25 +0200 Subject: [PATCH] Make plugin compatible with AllaganTools 1.7.1.1+ --- Influx/AllaganTools/FilterResult.cs | 17 ++++++++--------- Influx/AllaganTools/ListService.cs | 3 ++- Influx/Influx.csproj | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Influx/AllaganTools/FilterResult.cs b/Influx/AllaganTools/FilterResult.cs index 85be1aa..bb165f9 100644 --- a/Influx/AllaganTools/FilterResult.cs +++ b/Influx/AllaganTools/FilterResult.cs @@ -3,27 +3,26 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Threading.Tasks; namespace Influx.AllaganTools; internal sealed class FilterResult { - private readonly object _delegate; - private readonly PropertyInfo _sortedItems; + private readonly IEnumerable _searchResultList; - public FilterResult(object @delegate) + public FilterResult(IEnumerable searchResultList) { - ArgumentNullException.ThrowIfNull(@delegate); - _delegate = @delegate; - _sortedItems = - _delegate.GetType().GetProperty("SortedItems") ?? throw new MissingMemberException(); + ArgumentNullException.ThrowIfNull(searchResultList); + _searchResultList = searchResultList; } public IReadOnlyList GenerateFilteredList() { - return ((IEnumerable)_sortedItems.GetValue(_delegate)!) + return _searchResultList .Cast() + .Select(x => x.GetType() + .GetField("_sortingResult", BindingFlags.Instance | BindingFlags.NonPublic)! + .GetValue(x)!) .Select(x => new SortingResult(x)) .ToList(); } diff --git a/Influx/AllaganTools/ListService.cs b/Influx/AllaganTools/ListService.cs index 53dc2f0..934772b 100644 --- a/Influx/AllaganTools/ListService.cs +++ b/Influx/AllaganTools/ListService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Reflection; namespace Influx.AllaganTools; @@ -23,6 +24,6 @@ internal sealed class ListService : IListService public FilterResult? GetFilterByKeyOrName(string keyOrName) { var f = _getListByKeyOrName.Invoke(_listService, [keyOrName]); - return f != null ? new FilterResult(_refreshList.Invoke(_listFilterService, [f])!) : null; + return f != null ? new FilterResult((IEnumerable)_refreshList.Invoke(_listFilterService, [f])!) : null; } } diff --git a/Influx/Influx.csproj b/Influx/Influx.csproj index 13083db..3ded112 100644 --- a/Influx/Influx.csproj +++ b/Influx/Influx.csproj @@ -1,6 +1,6 @@ - 1.2 + 1.3 dist