本文整理汇总了C#中IUserAuth.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IUserAuth.ThrowIfNull方法的具体用法?C# IUserAuth.ThrowIfNull怎么用?C# IUserAuth.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserAuth
的用法示例。
在下文中一共展示了IUserAuth.ThrowIfNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateNewUserWithoutPassword
private void ValidateNewUserWithoutPassword(IUserAuth newUser)
{
newUser.ThrowIfNull("newUser");
if (newUser.UserName.IsNullOrEmpty() && newUser.Email.IsNullOrEmpty())
throw new ArgumentNullException("UserName or Email is required");
if (!newUser.UserName.IsNullOrEmpty())
{
if (!ValidUserNameRegEx.IsMatch(newUser.UserName))
throw new ArgumentException("UserName contains invalid characters", "UserName");
}
}
示例2: ValidateNewUser
private void ValidateNewUser(IUserAuth newUser, string password)
{
newUser.ThrowIfNull("newUser");
password.ThrowIfNullOrEmpty("password");
if (string.IsNullOrEmpty(newUser.UserName) && string.IsNullOrEmpty(newUser.Email))
throw new ArgumentNullException("UserName or Email is required");
if (!string.IsNullOrEmpty(newUser.UserName))
{
if (!HostContext.GetPlugin<AuthFeature>().IsValidUsername(newUser.UserName))
throw new ArgumentException("UserName contains invalid characters", "UserName");
}
}
示例3: ValidateNewUser
private void ValidateNewUser(IUserAuth newUser, string password)
{
newUser.ThrowIfNull("newUser");
password.ThrowIfNullOrEmpty("password");
if (string.IsNullOrEmpty(newUser.UserName) && string.IsNullOrEmpty(newUser.Email))
throw new ArgumentNullException("UserName or Email is required");
if (!string.IsNullOrEmpty(newUser.UserName))
{
if (!ValidUserNameRegEx.IsMatch(newUser.UserName))
throw new ArgumentException("UserName contains invalid characters", "UserName");
}
}
示例4: ValidateNewUser
private void ValidateNewUser(IUserAuth newUser, string password)
{
newUser.ThrowIfNull("newUser");
password.ThrowIfNullOrEmpty("password");
ValidateNewUser(newUser);
}
示例5: ValidateNewUser
/// <summary>
/// Validate new user.
/// </summary>
/// <param name="newUser">The new user.</param>
/// <param name="password">The password.</param>
/// <exception cref="ArgumentNullException">
/// Exception thrown if newUser is null.
/// </exception>
/// <exception cref="ArgumentException">
/// Exception thrown if password is null or empty.
/// </exception>
private void ValidateNewUser(IUserAuth newUser, string password)
{
newUser.ThrowIfNull("newUser");
password.ThrowIfNullOrEmpty("password");
// Check for username and email fields existence
if (newUser.UserName.IsNullOrEmpty()
&& newUser.Email.IsNullOrEmpty())
{
throw new ArgumentNullException("UserName or Email is required");
}
// Check for username validity based on Regex rule
if (!newUser.UserName.IsNullOrEmpty())
{
if (!this.ValidUserNameRegEx.IsMatch(newUser.UserName))
{
throw new ArgumentException("UserName contains invalid characters", "UserName");
}
}
}
开发者ID:hhandoko,项目名称:ServiceStack.Authentication.LightSpeed,代码行数:32,代码来源:LightSpeedUserAuthRepository.cs