当前位置: 首页>>代码示例>>C#>>正文


C# IUserAuth.ThrowIfNull方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:13,代码来源:RavenDbUserAuthRepository.cs

示例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");
            }
        }
开发者ID:rudygt,项目名称:ServiceStack,代码行数:14,代码来源:NHibernateUserAuthRepository.cs

示例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");
            }
        }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:14,代码来源:NHibernateUserAuthRepository.cs

示例4: ValidateNewUser

        private void ValidateNewUser(IUserAuth newUser, string password)
        {
            newUser.ThrowIfNull("newUser");
            password.ThrowIfNullOrEmpty("password");

            ValidateNewUser(newUser);
        }
开发者ID:Filimindji,项目名称:YAQAAP,代码行数:7,代码来源:AzureAuthProvider.cs

示例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


注:本文中的IUserAuth.ThrowIfNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。