From 4a029673ef45ae77ba4e84fac268ded0ee959b9e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 25 Aug 2021 08:52:05 -0500 Subject: add WithFilters options extension --- src/slskd/Application/Search/Extensions.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') 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 @@ -70,6 +70,34 @@ namespace slskd.Search }); } + /// + /// Returns a copy of the specified with the specified filter delegates overridden. + /// + /// + /// + /// + /// + public static SearchOptions WithFilters( + this SearchOptions options, + Func responseFilter = null, + Func 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); + } + /// /// Creates a projection over the specified which omits responses. /// -- cgit v1.2.3