private bool ValidateUserName(string username)
{
if (string.IsNullOrWhiteSpace(username))
{
return false;
}
if (username.Contains("@") && this.AllowEmailAsUserName)
{
return this.ValidateEmail(username, true, this.MaxUserNameLength);
}
if (username.Length > this.MaxUserNameLength)
{
return false;
}
if (this.UserNameRegularExpression.Length > 0)
{
if (!Regex.IsMatch(username, this.UserNameRegularExpression))
{
return false;
}
}
return true;
}
}