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


C# TempDataDictionary.Keep方法代码示例

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


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

示例1: Keep_DoesNotThrowException_WhenDataIsNotLoaded

        public void Keep_DoesNotThrowException_WhenDataIsNotLoaded()
        {
            // Arrange
            var tempData = new TempDataDictionary(GetHttpContextAccessor(), new SessionStateTempDataProvider());

            // Act & Assert
            tempData.Keep();
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:8,代码来源:TempDataDictionaryTest.cs

示例2: Does_not_throw_when_key_has_been_kept

        public void Does_not_throw_when_key_has_been_kept()
        {
            string key = "testkey";

            var tempData = new TempDataDictionary
            {
                {key, new object()}
            };

            tempData.Keep(key);
            tempData.AssertKept(key);
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:12,代码来源:TempDataTestExtensionsTests.cs

示例3: Throws_when_key_has_not_been_kept

        public void Throws_when_key_has_not_been_kept()
        {
            string key = "testkey";

            var tempData = new TempDataDictionary
            {
                {key, new object()}
            };

            tempData.Keep("nottestkey");

            Assert.Throws<MvcContrib.TestHelper.AssertionException>(
                () => tempData.AssertKept(key), "Key 'testkey' not kept.");
        }
开发者ID:atomicobject,项目名称:mvccontrib,代码行数:14,代码来源:TempDataTestExtensionsTests.cs

示例4: KeepRetainsAllKeysWhenSavingDictionary

        public void KeepRetainsAllKeysWhenSavingDictionary() {
            // Arrange
            NullTempDataProvider provider = new NullTempDataProvider();
            TempDataDictionary tempData = new TempDataDictionary();
            Mock<ControllerContext> controllerContext = new Mock<ControllerContext>();
            controllerContext.Setup(c => c.HttpContext.Request).Returns(new Mock<HttpRequestBase>().Object);
            tempData["Foo"] = "Foo";
            tempData["Bar"] = "Bar";

            // Act
            tempData.Keep();
            tempData.Save(controllerContext.Object, provider);

            // Assert
            Assert.IsTrue(tempData.ContainsKey("Foo"), "tempData should contain 'Foo'");
            Assert.IsTrue(tempData.ContainsKey("Bar"), "tempData should contain 'Bar'");
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:17,代码来源:TempDataDictionaryTest.cs

示例5: TempData_Keep_RetainsSpecificKeysWhenSavingDictionary

        public void TempData_Keep_RetainsSpecificKeysWhenSavingDictionary()
        {
            // Arrange
            var tempData = new TempDataDictionary(GetHttpContextAccessor(), new NullTempDataProvider());
            tempData["Foo"] = "Foo";
            tempData["Bar"] = "Bar";

            // Act
            var foo = tempData["Foo"];
            var bar = tempData["Bar"];
            tempData.Keep("Foo");
            tempData.Save();

            // Assert
            Assert.True(tempData.ContainsKey("Foo"));
            Assert.False(tempData.ContainsKey("Bar"));
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:17,代码来源:TempDataDictionaryTest.cs

示例6: TempData_Keep_RetainsAllKeysWhenSavingDictionary

        public void TempData_Keep_RetainsAllKeysWhenSavingDictionary()
        {
            // Arrange
            var tempData = new TempDataDictionary(new DefaultHttpContext(), new NullTempDataProvider());
            tempData["Foo"] = "Foo";
            tempData["Bar"] = "Bar";

            // Act
            tempData.Keep();
            tempData.Save();

            // Assert
            Assert.True(tempData.ContainsKey("Foo"));
            Assert.True(tempData.ContainsKey("Bar"));
        }
开发者ID:phinq19,项目名称:git_example,代码行数:15,代码来源:TempDataDictionaryTest.cs

示例7: KeepRetainsSpecificKeysWhenSavingDictionary

        public void KeepRetainsSpecificKeysWhenSavingDictionary()
        {
            // Arrange
            NullTempDataProvider provider = new NullTempDataProvider();
            TempDataDictionary tempData = new TempDataDictionary();
            Mock<ControllerContext> controllerContext = new Mock<ControllerContext>();
            controllerContext.Setup(c => c.HttpContext.Request).Returns(new Mock<HttpRequestBase>().Object);
            tempData["Foo"] = "Foo";
            tempData["Bar"] = "Bar";

            // Act
            tempData.Keep("Foo");
            object value = tempData["Bar"];
            tempData.Save(controllerContext.Object, provider);

            // Assert
            Assert.True(tempData.ContainsKey("Foo"));
            Assert.False(tempData.ContainsKey("Bar"));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:19,代码来源:TempDataDictionaryTest.cs

示例8: _AddMessages

        private static void _AddMessages(TempDataDictionary tempData, BarData bar, IEnumerable<string> messages)
        {
            var key = GetTempDataKeyFor(bar);

            if (tempData == null) throw new ArgumentNullException("tempData");

            if (!tempData.ContainsKey(key))
            {
                tempData[key] = new List<string>();
            }

            var statusData = tempData[key] as IList<string>;
            messages.ForEach(x => statusData.Add(x));
            tempData.Keep(key); // Ensure list will be kept around..
        }
开发者ID:evicertia,项目名称:HermaFx,代码行数:15,代码来源:AlertsBarExtensions.cs


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