sharp-chat/SharpChat.Protocol.SockChat/Users/UserManagerExtensions.cs

20 lines
831 B
C#
Raw Permalink Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Users;
using System;
namespace SharpChat.Protocol.SockChat.Users {
public static class UserManagerExtensions {
public static void GetUserBySockChatName(this UserManager users, string userName, Action<IUser> callback) {
if(userName == null)
throw new ArgumentNullException(nameof(userName));
if(callback == null)
throw new ArgumentNullException(nameof(callback));
users.GetUser(
u => userName.Equals(u.GetDisplayName(), StringComparison.InvariantCultureIgnoreCase)
|| userName.Equals(u.UserName, StringComparison.InvariantCultureIgnoreCase)
|| userName.Equals(u.NickName, StringComparison.InvariantCultureIgnoreCase),
callback
);
}
}
}