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


C# OperationContext.ThrowIfEmpty方法代码示例

本文整理汇总了C#中OperationContext.ThrowIfEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# OperationContext.ThrowIfEmpty方法的具体用法?C# OperationContext.ThrowIfEmpty怎么用?C# OperationContext.ThrowIfEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OperationContext的用法示例。


在下文中一共展示了OperationContext.ThrowIfEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckCaptcha

 public bool CheckCaptcha(OperationContext context, string captcha)
 {
     context.ThrowIfEmpty(captcha, ClientFaultCodes.ValueMissing, "captcha", "Captcha is missing.");
       //Magic captch allows testers or unit tests to bypass captcha
       if (captcha == _settings.MagicCaptcha)
     return true;
       if (_recaptchaService != null) {
     string clientIp = context.WebContext == null ? null : context.WebContext.IPAddress;
     _recaptchaService.Verify(captcha, clientIp); //will throw if not valid
       }
       return true;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:12,代码来源:LoginModule_ProcessService.cs

示例2: CheckUserName

 private string CheckUserName(OperationContext context, string userName)
 {
     context.ThrowIfEmpty(userName, ClientFaultCodes.ValueMissing, "UserName", userName, "User name may not be empty");
       userName = userName.Trim().ToLowerInvariant();
       context.ThrowIf(userName.Length < 3, LoginFaultCodes.UserNameTooShort, "UserName", userName, "User name is too short");
       return userName;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:7,代码来源:LoginModule.cs

示例3: CheckPasswordStrength

 private void CheckPasswordStrength(OperationContext context, string password)
 {
     context.ThrowIfEmpty(password, ClientFaultCodes.InvalidValue, "password", "Password may not be empty.");
       context.ThrowIf(password.Length > 100, ClientFaultCodes.InvalidValue, "password", "Password too long, max size: 100.");
       var pwdStrength = EvaluatePasswordStrength(password);
       var pwdOk = pwdStrength >= _settings.RequiredPasswordStrength;
       context.ThrowIf(!pwdOk, LoginFaultCodes.WeakPassword, "Password", "Password does not meet strength criteria");
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:8,代码来源:LoginModule_Management.cs


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