本文整理汇总了C#中Message.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Evaluate方法的具体用法?C# Message.Evaluate怎么用?C# Message.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.Evaluate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetOfMessage
public void TestGetOfMessage()
{
var model = new TagModel(new object());
model.PushTagStack();
model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
model.PushTagStack();
model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US");
var tag = new Message();
tag.Key = new MockAttribute(new Constant("c"));
Assert.That(tag.Evaluate(model), Is.EqualTo("defaultC"));
}
示例2: TestGetOfMessageInBundleGlobalScope
public void TestGetOfMessageInBundleGlobalScope()
{
var model = new TagModel(new object(), new MockSessionState());
try
{
model.Global[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
var tag = new Message();
tag.Key = new MockAttribute(new Constant("c"));
Assert.That(tag.Evaluate(model), Is.EqualTo("defaultC"));
} finally
{
TagModel.GlobalModel[FormatConstants.BUNDLE] = null;
}
}
示例3: TestGetOfMessageWithTwoParams
public void TestGetOfMessageWithTwoParams()
{
var model = new TagModel(new object());
model.PushTagStack();
model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/complex", "");
model.PushTagStack();
model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US");
var tag = new Message();
tag.Key = new MockAttribute(new Constant("twovars"));
var param1 = new Param();
param1.Body = new MockAttribute(new Constant("#1"));
tag.AddNestedTag(param1);
var param2 = new Param();
param2.Body = new MockAttribute(new Constant("#2"));
tag.AddNestedTag(param2);
Assert.That(tag.Evaluate(model), Is.EqualTo("two #1, #2 vars"));
}
示例4: TestGetOfMessageWithNamedBundle
public void TestGetOfMessageWithNamedBundle()
{
var model = new TagModel(new object(), new MockSessionState());
model.Session["myBundle"] = new ResourceBundle("FormatTags/compiled", "");
var tag = new Message();
tag.Key = new MockAttribute(new Constant("c"));
tag.Bundle = new MockAttribute(new Constant("myBundle"));
Assert.That(tag.Evaluate(model), Is.EqualTo("defaultC"));
}
示例5: TestGetOfMessageNoBundle
public void TestGetOfMessageNoBundle()
{
var model = new TagModel(new object(), new MockSessionState());
var tag = new Message();
tag.Key = new MockAttribute(new Constant("c"));
try
{
tag.Evaluate(model);
Assert.Fail("Expected exception");
} catch (TagException Te)
{
Assert.That(TagException.NoResourceBundleFoundInTagScope().Message,
Is.EqualTo(Te.MessageWithOutContext));
}
}
示例6: TestGetOfMessageInVarAndDifferentScope
public void TestGetOfMessageInVarAndDifferentScope()
{
var model = new TagModel(new object(), new MockSessionState());
model.PushTagStack();
model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
model.PushTagStack();
model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US");
var tag = new Message();
tag.Key = new MockAttribute(new Constant("c"));
tag.Var = new MockAttribute(new Constant("myVar"));
tag.Scope = new MockAttribute(new Constant(VariableScope.Session.ToString()));
Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty));
Assert.That(model.Page["myVar"], Is.Null);
Assert.That(model.Session["myVar"], Is.EqualTo("defaultC"));
}