本文整理汇总了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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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);
}
示例7: EvalReturnsNullIfExpressionDoesNotMatch
public void EvalReturnsNullIfExpressionDoesNotMatch() {
var obj = new { Foo = new { Biz = "Baz" } };
ViewDataDictionary vdd = new ViewDataDictionary(obj);
Assert.AreEqual(null, vdd.Eval("Foo.Bar"));
}
示例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"));
}
示例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);
}
示例10: EvalThrowsIfExpressionIsNull
public void EvalThrowsIfExpressionIsNull()
{
// Arrange
ViewDataDictionary vdd = new ViewDataDictionary();
// Act & Assert
Assert.ThrowsArgumentNullOrEmpty(
delegate { vdd.Eval(null); }, "expression");
}
示例11: EvalFormatWithEmptyFormatReturnsViewData
public void EvalFormatWithEmptyFormatReturnsViewData()
{
// Arrange
ViewDataDictionary vdd = new ViewDataDictionary();
vdd["foo"] = "value";
// Act
string formattedValue = vdd.Eval("foo", "");
// Assert
Assert.Equal("value", formattedValue);
}
示例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);
}
示例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"));
}
示例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);
}
示例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);
}