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


C# ModelStateDictionary.Merge方法代码示例

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


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

示例1: AddModelstateErrors

 public void AddModelstateErrors(ModelStateDictionary modelState)
 {
     if (_modelState != null && !_modelState.IsValid)
     {
         //TODO: This errors now and then.
         modelState.Merge(_modelState);
     }
 }
开发者ID:basicdays,项目名称:Guidelines,代码行数:8,代码来源:ErrorContext.cs

示例2: Validate

        public async Task<ModelStateDictionary> Validate(DefaultContext db, Controller controller, CancellationToken cancellationToken, bool isAdmin)
        {
            var modelStateDictionary = new ModelStateDictionary();

            modelStateDictionary.Merge(await ValidateGoogleCredentialsJson(controller, cancellationToken));

            UserProfile userProfile = UserProfileCache.GetDetail(db, UserId);
            Currency[] currencies = CurrencyCache.GetIndex(db);
            ValidateChangeClaAccessCurrency(userProfile, currencies, ref modelStateDictionary);
            ValidateLyonessId(db, ref modelStateDictionary);
            AddAdditionalInformation(userProfile, isAdmin);
            FixAddress();

            return modelStateDictionary;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:15,代码来源:AccountModelView.cs

示例3: MergeDoesNothingIfParameterIsNull

        public void MergeDoesNothingIfParameterIsNull()
        {
            // Arrange
            ModelStateDictionary fooDict = new ModelStateDictionary() { { "foo", new ModelState() } };

            // Act
            fooDict.Merge(null);

            // Assert
            Assert.Single(fooDict);
            Assert.True(fooDict.ContainsKey("foo"));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:12,代码来源:ModelStateDictionaryTest.cs

示例4: MergeCopiesDictionaryEntries

        public void MergeCopiesDictionaryEntries()
        {
            // Arrange
            ModelStateDictionary fooDict = new ModelStateDictionary() { { "foo", new ModelState() } };
            ModelStateDictionary barDict = new ModelStateDictionary() { { "bar", new ModelState() } };

            // Act
            fooDict.Merge(barDict);

            // Assert
            Assert.Equal(2, fooDict.Count);
            Assert.Equal(barDict["bar"], fooDict["bar"]);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:13,代码来源:ModelStateDictionaryTest.cs

示例5: MergeDoesNothingIfParameterIsNull

        public void MergeDoesNothingIfParameterIsNull()
        {
            // Arrange
            var dictionary = new ModelStateDictionary() { { "foo", new ModelStateEntry() } };

            // Act
            dictionary.Merge(null);

            // Assert
            Assert.Single(dictionary);
            Assert.True(dictionary.ContainsKey("foo"));
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:12,代码来源:ModelStateDictionaryTest.cs

示例6: MergeCopiesDictionaryEntries

        public void MergeCopiesDictionaryEntries()
        {
            // Arrange
            var dictionary1 = new ModelStateDictionary { { "foo", new ModelStateEntry() } };
            var dictionary2 = new ModelStateDictionary { { "bar", new ModelStateEntry() } };

            // Act
            dictionary1.Merge(dictionary2);

            // Assert
            Assert.Equal(2, dictionary1.Count);
            Assert.Equal(dictionary2["bar"], dictionary1["bar"]);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:13,代码来源:ModelStateDictionaryTest.cs

示例7: MergeCopiesDictionaryOverwritesExistingValues

        public void MergeCopiesDictionaryOverwritesExistingValues(string key)
        {
            // Arrange
            var dictionary1 = new ModelStateDictionary();
            dictionary1.SetModelValue(key, "RawValue1", "AttemptedValue1");
            dictionary1.AddModelError(key, "value1-Error1");
            dictionary1.AddModelError(key, "value1-Error2");
            dictionary1.SetModelValue("other-key", null, null);

            var dictionary2 = new ModelStateDictionary();
            dictionary2.SetModelValue(key, "RawValue2", "AttemptedValue2");
            dictionary2.AddModelError(key, "value2-Error1");

            // Act
            dictionary1.Merge(dictionary2);

            // Assert
            Assert.Equal(2, dictionary1.Count);
            var item = dictionary1["other-key"];
            Assert.Null(item.AttemptedValue);
            Assert.Null(item.RawValue);
            Assert.Empty(item.Errors);

            item = dictionary1[key];
            Assert.Equal("AttemptedValue2", item.AttemptedValue);
            Assert.Equal("RawValue2", item.RawValue);
            Assert.Collection(item.Errors,
                error => Assert.Equal("value2-Error1", error.ErrorMessage));
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:29,代码来源:ModelStateDictionaryTest.cs

示例8: MergeCopiesDictionaryEntries

        public void MergeCopiesDictionaryEntries()
        {
            // Arrange
            var dictionary1 = new ModelStateDictionary();
            dictionary1.SetModelValue("foo", "RawValue1", "AttemptedValue1");
            dictionary1.AddModelError("foo", "value1-Error1");
            dictionary1.AddModelError("foo", "value1-Error2");

            var dictionary2 = new ModelStateDictionary();
            dictionary2.SetModelValue("bar", "RawValue2", "AttemptedValue2");
            dictionary2.AddModelError("bar", "value2-Error1");

            // Act
            dictionary1.Merge(dictionary2);

            // Assert
            Assert.Equal(2, dictionary1.Count);
            var item = dictionary1["foo"];
            Assert.Equal("AttemptedValue1", item.AttemptedValue);
            Assert.Equal("RawValue1", item.RawValue);

            item = dictionary1["bar"];
            Assert.Equal("AttemptedValue2", item.AttemptedValue);
            Assert.Equal("RawValue2", item.RawValue);
            Assert.Collection(item.Errors,
                error => Assert.Equal("value2-Error1", error.ErrorMessage));
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:27,代码来源:ModelStateDictionaryTest.cs


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