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


C# TagModel.PushTagStack方法代码示例

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


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

示例1: TestGetOfMessageDifferentLocale

        public void TestGetOfMessageDifferentLocale()
        {
            var model = new TagModel(new object());
            model.PushTagStack();
            model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
            model.PushTagStack();
            model.Page[FormatConstants.LOCALE] = new CultureInfo("nl-NL");

            var tag = new Message();
            tag.Key = new MockAttribute(new Constant("c"));
            Assert.That(tag.Evaluate(model), Is.EqualTo("nederlandseC"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:12,代码来源:MessageTest.cs

示例2: Evaluate

 public string Evaluate(TagModel model)
 {
     var baseName = GetAsString(BaseName, model);
     var prefix = GetAsString(Prefix, model);
     IResourceBundle bundle = new ResourceBundle(baseName, prefix, BaseName.ResourceLocator);
     model.PushTagStack();
     model.Tag[FormatConstants.BUNDLE] = bundle;
     return GetAsString(Body, model) ?? string.Empty;
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:9,代码来源:Bundle.cs

示例3: TagAboveModelResolveTest

 public void TagAboveModelResolveTest()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack();
     model.Model["NewValue"] = "Model";
     Assert.That(model["NewValue"], Is.EqualTo("Model"));
     model.Tag["NewValue"] = "Tag";
     Assert.That(model["NewValue"], Is.EqualTo("Tag"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:9,代码来源:TagModelTest.cs

示例4: SeachInTagScopeEmpyScopeTwoScopesValuesOverride

 public void SeachInTagScopeEmpyScopeTwoScopesValuesOverride()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack();
     model.Tag["a"] = 0;
     model.PushTagStack();
     model.Tag["a"] = 1;
     Assert.That(model.SearchInTagScope("a"), Is.EqualTo(1));
     model.PopTagStack();
     Assert.That(model.SearchInTagScope("a"), Is.EqualTo(0));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:11,代码来源:TagModelTest.cs

示例5: SeachInTagScopeEmpyScopeThreeScopesValueInTheSecondScope

 public void SeachInTagScopeEmpyScopeThreeScopesValueInTheSecondScope()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack();
     model.PushTagStack();
     model.Tag["a"] = 1;
     model.PushTagStack();
     Assert.That(model.SearchInTagScope("a"), Is.EqualTo(1));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:9,代码来源:TagModelTest.cs

示例6: TagModel

 public void PushTagWithPeekInParentShouldResolveParentValuesWithOutTrhowinngReflectionExceptionsOnUnknownPathsOnChild()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack(true);
     model["Tag.NewValue"] = "abc";
     Assert.That(model["NewValue"], Is.EqualTo("abc"));
     Assert.That(model["OtherValue"], Is.Null);
     model.PushTagStack(true);
     model["Tag.OtherValue"] = "def";
     Assert.That(model["OtherValue"], Is.EqualTo("def"));
     Assert.That(model["NewValue"], Is.EqualTo("abc"));
     model.PopTagStack();
     Assert.That(model["NewValue"], Is.EqualTo("abc"));
     Assert.That(model["OtherValue"], Is.Null);
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:15,代码来源:TagModelTest.cs

示例7: TestGetOfMessageNonExisting

        public void TestGetOfMessageNonExisting()
        {
            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("missing"));
            Assert.That(tag.Evaluate(model), Is.EqualTo("?missing?"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:12,代码来源:MessageTest.cs

示例8: TestPushingAndPoppingOfTagStack

 public void TestPushingAndPoppingOfTagStack()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack();
     model.Tag["NewValue"] = "abc";
     Assert.That(model.Tag["NewValue"], Is.EqualTo("abc"));
     model.PushTagStack();
     Assert.That(model.Tag["NewValue"], Is.Null);
     model.Tag["NewValue"] = "def";
     Assert.That(model.Tag["NewValue"], Is.EqualTo("def"));
     model.PopTagStack();
     Assert.That(model.Tag["NewValue"], Is.EqualTo("abc"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:13,代码来源:TagModelTest.cs

示例9: TagTest

 public void TagTest()
 {
     var model = new TagModel(new Reflection(new Hashtable()));
     model.PushTagStack();
     model.Tag["NewValue"] = "abc";
     Assert.That(model.Tag["NewValue"], Is.EqualTo("abc"));
     Assert.That(model[VariableScope.Tag + ".NewValue"], Is.EqualTo("abc"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:8,代码来源:TagModelTest.cs

示例10: TestGetTranslationWithResourceBundleInModel

 public void TestGetTranslationWithResourceBundleInModel()
 {
     var model = new TagModel(new object());
     model.PushTagStack();
     model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
     model.PushTagStack();
     CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture;
     Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
     try
     {
         Assert.That(ResourceBundle.GetMessage("b", model), Is.EqualTo("defaultB"));
     }
     finally
     {
         Thread.CurrentThread.CurrentCulture = oldCulture;
     }
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:17,代码来源:ResourceBundleTest.cs

示例11: TestGetTranslationWithResourceBundleAndLocaleInModel

 public void TestGetTranslationWithResourceBundleAndLocaleInModel()
 {
     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");
     Assert.That(ResourceBundle.GetMessage("b", model), Is.EqualTo("defaultB"));
     model.Page[FormatConstants.LOCALE] = new CultureInfo("nl-NL");
     Assert.That(ResourceBundle.GetMessage("b", model), Is.EqualTo("nederlandseB"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:11,代码来源:ResourceBundleTest.cs

示例12: Evaluate

 public string Evaluate(TagModel model)
 {
     var builder = new StringBuilder();
     IList list = ToList(GetIEnumerable(model));
     int start = GetAutoValueAsInt("Begin", model).Value;
     int end = GetAsInt(End, model) ?? list.Count;
     int step = GetAutoValueAsInt("Step", model).Value;
     string var = GetAutoValueAsString("Var", model);
     string varStatus = GetAutoValueAsString("VarStatus", model);
     model.PushTagStack();
     var status = new ForEachStatus(list.Count, start, end);
     if (list.Count > 0)
     {
         model.Tag[varStatus] = status;
         for (int i = start; i < end; i += step)
         {
             status.Index = i;
             model.Tag[var] = list[i];
             builder.Append(GetAsString(Body, model) ?? String.Empty);
         }
         model.Tag[var] = null;
         model.Tag[varStatus] = null;
     }
     model.PopTagStack();
     return builder.ToString();
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:26,代码来源:BaseIterationTag.cs

示例13: TestGetOfMessageWithWrongNestedType

        public void TestGetOfMessageWithWrongNestedType()
        {
            var model = new TagModel(new object());
            model.PushTagStack();
            model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "");
            model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US");

            var tag = new Message();
            tag.Key = new MockAttribute(new Constant("c"));
            try
            {
                tag.AddNestedTag(new Out());
            }
            catch (TagException Te)
            {
                Assert.That(Te.Message,
                            Is.EqualTo(TagException.OnlyNestedTagsOfTypeAllowed(typeof (Out), typeof (Param)).Message));
            }
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:19,代码来源:MessageTest.cs

示例14: 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

示例15: TestGetOfMessageWithBundleWithPrefix

        public void TestGetOfMessageWithBundleWithPrefix()
        {
            var model = new TagModel(new object());
            model.PushTagStack();
            model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", "pre_");
            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("prefixedC"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:12,代码来源:MessageTest.cs


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