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


C# ModelStateDictionary.Select方法代码示例

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


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

示例1: DictionnaryHasValueAndError

 public static void DictionnaryHasValueAndError(ModelStateDictionary dict, string value, string error)
 {
     Assert.AreEqual(1, dict.Count);
     var errors = dict.Select(x => x.Value.Errors).Where(y => y.Count > 0).ToList();
     var values = dict.Select(x => x.Key).ToList();
     foreach (var cur in values)
         Assert.AreEqual(value, cur);
     foreach (var cur in errors)
         foreach (var cur2 in cur)
             Assert.AreEqual(error, cur2.ErrorMessage);
 }
开发者ID:charla-n,项目名称:ManahostManager,代码行数:11,代码来源:DictionnaryAssert.cs

示例2: SerialiseModelState

        protected string SerialiseModelState(ModelStateDictionary modelState)
        {
            var entries = modelState
                .Select(m => new ModelStateTransferEntry(m.Key, m.Value))
                .ToList();

            return JsonConvert.SerializeObject(entries, JsonSettings);
        }
开发者ID:ankn85,项目名称:apex,代码行数:8,代码来源:ModelStateTransfer.cs

示例3: AddModelStateErrors

 public void AddModelStateErrors(ModelStateDictionary modelState)
 {
     foreach (var modelStateErrors in modelState.Select(x => x.Value.Errors))
     {
         foreach (var error in modelStateErrors)
         {
             Errors.Add(error.ErrorMessage);
         }
     }
 }
开发者ID:EliotJones,项目名称:IdentityTutorial,代码行数:10,代码来源:ErrorsViewModel.cs

示例4: ModelStateValidationJsonResult

 /// <summary>
 /// Returns a JSON result that contains model errors.
 /// </summary>
 public ModelStateValidationJsonResult(ModelStateDictionary state)
 {
     Data = new
     {
         Errors = state.Select(model => new
         {
             model.Key,
             Messages = model.Value.Errors.Select(e => e.ErrorMessage)
         })
     };
 }
开发者ID:bevacqua,项目名称:Swarm,代码行数:14,代码来源:ModelStateValidationJsonResult.cs

示例5: MvcFormValidationResult

    /// <summary>
    /// 创建 MvcFormValidationResult 对象
    /// </summary>
    /// <param name="form">所验证的表单</param>
    /// <param name="modelStates">要包装的模型验证状态</param>
    public MvcFormValidationResult( HtmlForm form, ModelStateDictionary modelStates )
    {
      if ( modelStates == null )
        throw new ArgumentNullException( "modelState" );

      Errors = new FormValidationErrorCollection();
      Form = form;


      modelStates.Select( CreateValidationError ).NotNull().ForAll( e => Errors.Add( e ) );

      if ( Errors.Any() )
        HasError = true;
    }
开发者ID:ajayumi,项目名称:Jumony,代码行数:19,代码来源:MvcFormValidationResult.cs

示例6: PrepareErrMsg

        private string PrepareErrMsg(ModelStateDictionary mdl) {
            List<ModelErrorCollection> errors = mdl.Select(x => x.Value.Errors).ToList();
            String msg = string.Empty;

            foreach (ModelErrorCollection error in errors)
            {
                foreach (ModelError modelError in error)
                {
                    msg += msg + modelError.ErrorMessage + " ";
                }

            }
            return msg;
        }
开发者ID:CloudMetal,项目名称:Liveo.Deployment,代码行数:14,代码来源:WidgetStylerController.cs


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