aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-08-25 08:52:05 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-08-25 08:52:05 -0500
commit4a029673ef45ae77ba4e84fac268ded0ee959b9e (patch)
tree6e5e1cb0c0c92461c57be6b8b2ee108f49f11a4e /src
parentf76808ace5a967f23556c022b3fe4fcc84f55e29 (diff)
downloadslskd-4a029673ef45ae77ba4e84fac268ded0ee959b9e.tar.gz
add WithFilters options extension
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application/Search/Extensions.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/slskd/Application/Search/Extensions.cs b/src/slskd/Application/Search/Extensions.cs
index d52975d2..149e0a14 100644
--- a/src/slskd/Application/Search/Extensions.cs
+++ b/src/slskd/Application/Search/Extensions.cs
@@ -71,6 +71,34 @@ namespace slskd.Search
}
/// <summary>
+ /// Returns a copy of the specified <paramref name="options"/> with the specified filter delegates overridden.
+ /// </summary>
+ /// <param name="options"></param>
+ /// <param name="responseFilter"></param>
+ /// <param name="fileFilter"></param>
+ /// <returns></returns>
+ public static SearchOptions WithFilters(
+ this SearchOptions options,
+ Func<SearchResponse, bool> responseFilter = null,
+ Func<Soulseek.File, bool> fileFilter = null)
+ {
+ return new SearchOptions(
+ options.SearchTimeout,
+ options.ResponseLimit,
+ filterResponses: options.FilterResponses || responseFilter != null || fileFilter != null,
+ options.MinimumResponseFileCount,
+ options.MinimumPeerFreeUploadSlots,
+ options.MaximumPeerQueueLength,
+ options.MinimumPeerUploadSpeed,
+ options.FileLimit,
+ options.RemoveSingleCharacterSearchTerms,
+ responseFilter,
+ fileFilter,
+ options.StateChanged,
+ options.ResponseReceived);
+ }
+
+ /// <summary>
/// Creates a projection over the specified <paramref name="query"/> which omits responses.
/// </summary>
/// <param name="query"></param>