diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-05-28 15:02:09 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-05-28 15:02:09 -0500 |
| commit | 770e931191983638dd3c422720af014779ad75ad (patch) | |
| tree | 224a68578959fbe2dc94e7f430393e1312d09442 /src | |
| parent | d3688262afeb01cf5ffd6df0c5ac2cbb1a8a6459 (diff) | |
| download | slskd-770e931191983638dd3c422720af014779ad75ad.tar.gz | |
docs
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Search/Extensions.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/slskd/Core/Search/Extensions.cs b/src/slskd/Core/Search/Extensions.cs index 2ff1139c..d52975d2 100644 --- a/src/slskd/Core/Search/Extensions.cs +++ b/src/slskd/Core/Search/Extensions.cs @@ -18,10 +18,18 @@ namespace slskd.Search { using System; + using System.Linq; using Soulseek; public static class Extensions { + /// <summary> + /// Returns a copy of the specified <paramref name="options"/> with the specified actions bound, while retaining the existing actions. + /// </summary> + /// <param name="options"></param> + /// <param name="stateChanged"></param> + /// <param name="responseReceived"></param> + /// <returns></returns> public static SearchOptions WithActions( this SearchOptions options, Action<SearchStateChangedEventArgs> stateChanged = null, @@ -61,5 +69,26 @@ namespace slskd.Search responseReceived(args); }); } + + /// <summary> + /// Creates a projection over the specified <paramref name="query"/> which omits responses. + /// </summary> + /// <param name="query"></param> + /// <returns></returns> + public static IQueryable<Search> WithoutResponses(this IQueryable<Search> query) + { + return query.Select(s => new Search() + { + Id = s.Id, + StartedAt = s.StartedAt, + EndedAt = s.EndedAt, + FileCount = s.FileCount, + LockedFileCount = s.LockedFileCount, + ResponseCount = s.ResponseCount, + SearchText = s.SearchText, + State = s.State, + Token = s.Token, + }); + } } } |
