public string Evaluate(TagModel model) { model.PushTagStack(); object result = Body != null ? Body.Evaluate(model) : String.Empty; model.PopTagStack(); return result != null ? result.ToString() : null; }
private static void Tile() { try { Console.WriteLine("Rendering tile"); var set = new TilesSet( new TileXmlConfigurator("tiles.xml")); var model = new TagModel(new Hashtable { { "Key", new List<Person> { new Person {Name = "Ruth Kingsley", Age = 42}, new Person {Name = "Jacob van Dijk", Age = 23}, new Person {Name = "Stuward Langley", Age = 66} } } }).UpdateFactory(new FileLocatorFactory()); Console.WriteLine(set["template"].Render(model)); } catch (ExceptionWithContext EWC) { Console.WriteLine(EWC.Message); Console.WriteLine(EWC.Context); } Console.WriteLine("Hit enter"); Console.ReadLine(); }
public override object InternalEvaluate(TagModel model) { var helper = (UrlHelper) model.Page[Html.PAGE_MODEL_URLHELPER_INSTANCE]; var actionName = GetAsString(Action, model); var controllerName = GetAsString(Controller, model); return !String.IsNullOrEmpty(controllerName) ? helper.Action(actionName, controllerName) : helper.Action(actionName); }
public void Test_IsAuthenticated_Through_TagModel() { var request = new MockContextBase.MockRequestBase(); var requestBase = new HttpRequestBaseWrapper(request); var model = new TagModel(null, null, requestBase, null); Assert.That(model["Request.IsAuthenticated"], Is.False); request.ManualAuthenticated = true; Assert.That(model["Request.IsAuthenticated"], Is.True); }
public object Value(TagModel model) { object value = null; if (Attribute != null) { value = Attribute.Evaluate(model); } return value; }
public void Test_Params_Through_TagModel() { var request = new MockContextBase.MockRequestBase(); var requestBase = new HttpRequestBaseWrapper(request); var model = new TagModel(null, null, requestBase, null); request.Params["X"] = "1"; Assert.That(model["Request.X"], Is.EqualTo("1")); request.Params["X"] = "2"; Assert.That(model["Request.X"], Is.EqualTo("2")); }
public object Evaluate(TagModel model) { try { return _expression.Evaluate(model); } catch (ReflectionException Re) { throw ReflectionException.DecorateWithContext(Re, Context); } }
public void Render(ViewContext viewContext, TextWriter writer) { HttpContextBase context = viewContext.HttpContext; ViewDataDictionary model = viewContext.ViewData; HttpRequestBase request = context.Request; ITile tile = GetView(_viewName); var tagModel = new TagModel(model.Model ?? model, new SimpleHttpSessionState(), new HttpContextBaseResponseWrapper(context, request.ApplicationPath)); tagModel.Page["request"] = request.Params; writer.Write(tile.Render(tagModel)); }
public string Evaluate(TagModel model) { try { string tileName = GetAutoValueAsString("Name", model); bool mandatory = GetAutoValueAsBool("Mandatory", model); using (var stack = new TagModelAttributeStack(model)) { if (!mandatory && !stack.Current.HasDefinitionFor(tileName)) return String.Empty; string result = stack.Current[tileName].Value.Render(model); return result ?? String.Empty; } } catch (TileException Te) { throw TileExceptionWithContext.ErrorInTile(Te, Context); } }
public object Evaluate(TagModel model) { try { return _tag.Evaluate(model); } catch (ExceptionWithContext EWC) { if (EWC.Context == null) { throw ExceptionWithContext.MakePartial(EWC).Decorate(_tag.Context); } throw EWC; } catch (Exception e) { throw TagException.EvaluationError(e).Decorate(_tag.Context); } }
public string Render(TagModel model, AttributeSet attributes) { return _value; }
public void SetUp() { tile = new TemplateTile( "test", new FileTemplate("b.htm"), new List<TileAttribute>() ); model = new TagModel(new Hashtable { { "some", new Hashtable { { "a", "b" } } } }); }
public string Evaluate(TagModel model) { return Template.Evaluate(model); }
public string Evaluate(TagModel model) { string result = GetAutoValueAsString("Value", model); System.Console.WriteLine(result); return string.Empty; }
public object Evaluate(TagModel model) { return(ConstantValue); }
public object Evaluate(TagModel model) { return ConstantValue; }
public void FormatAndSave(TagModel source, string path) { FormatAndSave(source, path, Encoding.UTF8); }
public void SetUp() { _lib = new TagLib(); _lib.Register(new Tags.Tiles()); _lib.Register(new Sharp()); _factory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory; _map = new TilesMap(); _data = new Hashtable(); _model = new TagModel(_data); _nestedAttributes = new AttributeSet( "nested", new TileAttribute("aAttribute", new StringTile("aAttributeValue")) ); _map.AddTile(new TemplateTile("fileWithAttributes", _factory.Handle("filewithtileattributes.htm", true), _nestedAttributes)); _attributes = new AttributeSet( "main", new TileAttribute("simple", new StringTile("simpleValue")), new TileAttribute("file", new TemplateTile(null, _factory.Handle("a.htm", true), null)), new TileAttribute("fileWithVars", new TemplateTile(null, _factory.Handle("b.htm",true), null)), new TileAttribute("fileWithTilesAttributes", new TileReference("fileWithAttributes", _map)) ); _model.Decorate().With(_attributes); _data["simpleAsProperty"] = "simple"; _data["some"] = new Hashtable {{"a", "AA"}}; }
public string Format(TagModel model) { return _templateParsed.Evaluate(model); }
public string Evaluate(TagModel model) { throw new System.NotImplementedException(); }
public string Render(TagModel model) { return _value; }
public object Evaluate(TagModel model) { return _expression.Evaluate(model); }
protected override void Render(HtmlTextWriter writer) { ITile tile = TILES[_view]; var model = new TagModel(_model, new SimpleHttpSessionState(), null, new PageWrapper(Page)); model.Page["Request"] = Page.Request.Params; writer.Write(tile.Render(model)); }
public string Format(object source) { TagModel model = new TagModel(source); return _templateParsed.Evaluate(model); }
public TagModelAttributeStack(TagModel model) { _model = model; GuardTagAttributeStack(); }
public void FormatAndSave(object source, string path, Encoding fallBack) { var model = new TagModel(source); var formatted = _templateParsed.Evaluate(model); var data = (model.Encoding ?? fallBack).GetBytes(formatted); File.WriteAllBytes(path, data); }
private IEnumerable<IAttributeEntry> AsAttributeEntries(TagModel model) { return _nestedTags.Select(n => n.Yield(model)); }
public void FormatAndSave(TagModel model, string path, Encoding fallBack) { string formatted = _templateParsed.Evaluate(model); byte[] data = (model.Encoding ?? fallBack).GetBytes(formatted); File.WriteAllBytes(path, data); }
private void LoadTile(TagModel model, string tileName) { lock (this) { if (_tile == null || !Equals(tileName, _tile.Name)) { var template = Factory.Handle(tileName, ResourceLocator, true); _tile = new TemplateTile( tileName, template, new TilesFactory(Factory).CreateAttributes(AsAttributeEntries(model))); } } }
public void TearDown() { _map = null; _data = null; _model = null; _attributes = null; _nestedAttributes = null; }
public string Evaluate(TagModel model) { var tileName = GetAutoValueAsString("Template", model); try { LoadTile(model, tileName); return _tile.Render(model) ?? String.Empty; } catch (TileExceptionWithContext) { throw; } catch (TileException) { throw; } catch (ExceptionWithContext EWC) { throw TileExceptionWithContext.ErrorInTile(tileName, EWC); } catch (Exception e) { throw TileException.ErrorInTile(tileName, e); } }