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


C# Message.Evaluate方法代码示例

本文整理汇总了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"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:12,代码来源:MessageTest.cs

示例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;
            }
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:15,代码来源:MessageTest.cs

示例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"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:21,代码来源:MessageTest.cs

示例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"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:10,代码来源:MessageTest.cs

示例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));
     }
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:15,代码来源:MessageTest.cs

示例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"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:16,代码来源:MessageTest.cs


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