diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-02-23 09:28:32 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-02-23 09:28:32 -0600 |
| commit | a6508a390021f82ffd3c81f8001c914889f23f28 (patch) | |
| tree | 0931a5ba3a8d6ab1c00a3c01b88c9254f67540d8 /src/slskd/Users/Extensions.cs | |
| parent | ec21875fb748bc91b4df85ea62c4813815e25b4a (diff) | |
| download | slskd-a6508a390021f82ffd3c81f8001c914889f23f28.tar.gz | |
use extensions over static factory methods
Diffstat (limited to 'src/slskd/Users/Extensions.cs')
| -rw-r--r-- | src/slskd/Users/Extensions.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/slskd/Users/Extensions.cs b/src/slskd/Users/Extensions.cs new file mode 100644 index 00000000..f485df34 --- /dev/null +++ b/src/slskd/Users/Extensions.cs @@ -0,0 +1,51 @@ +// <copyright file="Extensions.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd.Users +{ + using Soulseek; + + /// <summary> + /// Users extensions. + /// </summary> + public static class Extensions + { + /// <summary> + /// Converts <see cref="Soulseek.UserStatistics"/> to <see cref="Statistics"/>. + /// </summary> + /// <param name="u">The UserStatistics instance to convert.</param> + /// <returns>The converted instance.</returns> + public static Statistics AsStatistics(this UserStatistics u) => new() + { + AverageSpeed = u.AverageSpeed, + DirectoryCount = u.DirectoryCount, + FileCount = u.FileCount, + UploadCount = u.UploadCount, + }; + + /// <summary> + /// Converts <see cref="Soulseek.UserStatus"/> to <see cref="Status"/>. + /// </summary> + /// <param name="s">The UserStatus instance to convert.</param> + /// <returns>The converted instance.</returns> + public static Status AsStatus(this UserStatus s) => new() + { + IsPrivileged = s.IsPrivileged, + Presence = s.Presence, + }; + } +} |
