diff options
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, + }); + } } } |
