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


C# ViewDataDictionary.Eval方法代码示例

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


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

示例1: EvalReturnsSimplePropertyValue

        public void EvalReturnsSimplePropertyValue()
        {
            var obj = new { Foo = "Bar" };
            ViewDataDictionary vdd = new ViewDataDictionary(obj);

            Assert.Equal("Bar", vdd.Eval("Foo"));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:7,代码来源:ViewDataDictionaryTest.cs

示例2: EvalWithModelAndDictionaryPropertyEvaluatesDictionaryValue

        public void EvalWithModelAndDictionaryPropertyEvaluatesDictionaryValue()
        {
            var obj = new { Foo = new Dictionary<string, object> { { "Bar", "Baz" } } };
            ViewDataDictionary vdd = new ViewDataDictionary(obj);

            Assert.Equal("Baz", vdd.Eval("Foo.Bar"));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:7,代码来源:ViewDataDictionaryTest.cs

示例3: EvalEvaluatesDictionaryThenModel

        public void EvalEvaluatesDictionaryThenModel() {
            var obj = new { Foo = "NotBar" };
            ViewDataDictionary vdd = new ViewDataDictionary(obj);
            vdd.Add("Foo", "Bar");

            Assert.AreEqual("Bar", vdd.Eval("Foo"));
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:7,代码来源:ViewDataDictionaryTest.cs

示例4: EvalChoosesValueInDictionaryOverOtherValue

        public void EvalChoosesValueInDictionaryOverOtherValue() {
            ViewDataDictionary vdd = new ViewDataDictionary();
            vdd.Add("Foo", new { Bar = "Not Baz" });
            vdd.Add("Foo.Bar", "Baz");

            Assert.AreEqual("Baz", vdd.Eval("Foo.Bar"));
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:7,代码来源:ViewDataDictionaryTest.cs

示例5: EvalWithCompoundIndexAndCompoundExpressionReturnsValue

        public void EvalWithCompoundIndexAndCompoundExpressionReturnsValue() {
            ViewDataDictionary vdd = new ViewDataDictionary();
            vdd.Add("Foo.Bar", new { Baz = new { Blah = "Quux" } });

            Assert.AreEqual("Quux", vdd.Eval("Foo.Bar.Baz.Blah"));
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:6,代码来源:ViewDataDictionaryTest.cs

示例6: EvalChoosesCompoundValueInDictionaryOverOtherValuesWithCompoundProperty

        public void EvalChoosesCompoundValueInDictionaryOverOtherValuesWithCompoundProperty()
        {
            // Arrange
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider())
            {
                { "Foo", new Person() },
                { "Foo.Bar", new { Baz = "Quux" } }
            };

            // Act
            var result = viewData.Eval("Foo.Bar.Baz");

            // Assert
            Assert.Equal("Quux", result);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:15,代码来源:ViewDataDictionaryTest.cs

示例7: EvalReturnsNullIfExpressionDoesNotMatch

        public void EvalReturnsNullIfExpressionDoesNotMatch() {
            var obj = new { Foo = new { Biz = "Baz" } };
            ViewDataDictionary vdd = new ViewDataDictionary(obj);

            Assert.AreEqual(null, vdd.Eval("Foo.Bar"));
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:6,代码来源:ViewDataDictionaryTest.cs

示例8: EvalWithCompoundExpressionAndDictionarySubExpressionChoosesDictionaryValue

        public void EvalWithCompoundExpressionAndDictionarySubExpressionChoosesDictionaryValue() {
            ViewDataDictionary vdd = new ViewDataDictionary();
            vdd.Add("Foo", new Dictionary<string, object> { { "Bar", "Baz" } });

            Assert.AreEqual("Baz", vdd.Eval("Foo.Bar"));
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:6,代码来源:ViewDataDictionaryTest.cs

示例9: EvalWithCompoundExpressionAndDictionarySubExpressionChoosesDictionaryValue

        public void EvalWithCompoundExpressionAndDictionarySubExpressionChoosesDictionaryValue()
        {
            // Arrange
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
            viewData.Add("Foo", new Dictionary<string, object> { { "Bar", "Baz" } });

            // Act
            var result = viewData.Eval("Foo.Bar");

            // Assert
            Assert.Equal("Baz", result);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:12,代码来源:ViewDataDictionaryTest.cs

示例10: EvalThrowsIfExpressionIsNull

        public void EvalThrowsIfExpressionIsNull()
        {
            // Arrange
            ViewDataDictionary vdd = new ViewDataDictionary();

            // Act & Assert
            Assert.ThrowsArgumentNullOrEmpty(
                delegate { vdd.Eval(null); }, "expression");
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:9,代码来源:ViewDataDictionaryTest.cs

示例11: EvalFormatWithEmptyFormatReturnsViewData

        public void EvalFormatWithEmptyFormatReturnsViewData()
        {
            // Arrange
            ViewDataDictionary vdd = new ViewDataDictionary();
            vdd["foo"] = "value";

            // Act
            string formattedValue = vdd.Eval("foo", "");

            // Assert
            Assert.Equal("value", formattedValue);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:12,代码来源:ViewDataDictionaryTest.cs

示例12: EvalFormatWithFormatReturnsFormattedViewData

        public void EvalFormatWithFormatReturnsFormattedViewData()
        {
            // Arrange
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
            viewData["foo"] = "value";

            // Act
            var formattedValue = viewData.Eval("foo", "for{0}mat");

            // Assert
            Assert.Equal("forvaluemat", formattedValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:12,代码来源:ViewDataDictionaryTest.cs

示例13: EvalChoosesCompoundValueInDictionaryOverOtherValues

        public void EvalChoosesCompoundValueInDictionaryOverOtherValues()
        {
            ViewDataDictionary vdd = new ViewDataDictionary();
            vdd.Add("Foo", new { Bar = new { Baz = "Not Quux" } });
            vdd.Add("Foo.Bar", new { Baz = "Quux" });

            Assert.Equal("Quux", vdd.Eval("Foo.Bar.Baz"));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:8,代码来源:ViewDataDictionaryTest.cs

示例14: EvalFormatWithNullValueReturnsEmptyString

        public void EvalFormatWithNullValueReturnsEmptyString()
        {
            // Arrange
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());

            // Act
            var formattedValue = viewData.Eval("foo", "for{0}mat");

            // Assert
            Assert.Empty(formattedValue);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:11,代码来源:ViewDataDictionaryTest.cs

示例15: EvalWithNestedDictionariesEvalCorrectly

        public void EvalWithNestedDictionariesEvalCorrectly()
        {
            // Arrange
            var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
            viewData.Add("Foo", new Dictionary<string, object> { { "Bar", new Hashtable { { "Baz", "Quux" } } } });

            // Act
            var result = viewData.Eval("Foo.Bar.Baz");

            // Assert
            Assert.Equal("Quux", result);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:12,代码来源:ViewDataDictionaryTest.cs


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