public string Render(AbstractNode node, object model) { var modelValueProviderFactory = _host.DependencyResolver.Resolve<IModelValueProviderFactory>(); if (node == null) { throw new ArgumentNullException("node"); } var stringNode = node as StringLiteral; if (stringNode == null) { throw new InvalidCastException("node"); } string result = ""; foreach (var value in stringNode.Values) { result += GetModelValue(modelValueProviderFactory, model, value.Type, value.Data); } //return RendererHelpers.GetModelValue(model, stringNode.Parrot.Infrastructure.ValueType, stringNode) return result; //return stringNode.GetValue() as string; }
public void AppendChildNode(AbstractNode node) { if (node == null) { return; } m_array.Add(node); }
public string Render(AbstractNode node, object model) { dynamic localModel = model; Document document = new Document(_host) { Children = localModel.Children }; return _host.DependencyResolver.Resolve<DocumentRenderer>().Render(document, localModel.Model); }
public string Render(AbstractNode node, object documentHost) { if (documentHost != null) { var modelValueProviderFactory = _host.DependencyResolver.Resolve<IModelValueProviderFactory>(); var value = modelValueProviderFactory.Get(documentHost.GetType()).GetValue(documentHost, Parrot.Infrastructure.ValueType.Property, (node as Statement).Name); return value.ToString(); } return (node as Statement).Name; }
public string Render(AbstractNode node, object model) { if (node == null) { throw new ArgumentNullException("node"); } var stringNode = node as StringLiteralNode; if (stringNode == null) { throw new InvalidCastException("node"); } return stringNode.GetValue() as string; }
public string Render(AbstractNode node, object model) { if (node == null) { throw new ArgumentNullException("node"); } var outputNode = node as OutputNode; if (outputNode == null) { throw new ArgumentNullException("node"); } node.SetModel(model); return node.ToString(); }
public override string Render(AbstractNode node, object model) { if (node == null) { throw new ArgumentNullException("node"); } var blockNode = node as BlockNode; if (blockNode == null) { throw new ArgumentException("node"); } var tag = CreateTag(model, blockNode); return tag.ToString(TagRenderMode.SelfClosing); }
public virtual string Render(AbstractNode node, object model) { if (node == null) { throw new ArgumentNullException("node"); } var blockNode = node as Statement; if (blockNode == null) { throw new ArgumentException("node"); } var tag = CreateTag(model, blockNode); return tag.ToString(); }
public string Render(AbstractNode node, object model) { if (node == null) { throw new ArgumentNullException("node"); } var blockNode = node as BlockNode; //this tag can't have any children if (blockNode.Children.Any()) { throw new Exception("Block can't have any children"); } var localModel = model; TagBuilder tag = new TagBuilder("input"); foreach (var attribute in blockNode.Attributes.Cast<AttributeNode>()) { attribute.SetModel(localModel); if (attribute.Key == "class") { tag.AddCssClass(attribute.GetValue()); } else { tag.MergeAttribute(attribute.Key, attribute.GetValue(), true); } } //check and see if there's a parameter and assign it to value if (blockNode.Parameters != null && blockNode.Parameters.Count == 1) { //grab only the first var parameter = blockNode.Parameters[0]; string value = parameter.Value; tag.MergeAttribute("value", value, true); } return tag.ToString(TagRenderMode.SelfClosing); }
public string Render(AbstractNode node, object model) { var modelValueProviderFactory = _host.DependencyResolver.Resolve<IModelValueProviderFactory>(); if (node == null) { throw new ArgumentNullException("node"); } var outputNode = node as RawOutput; if (outputNode == null) { throw new ArgumentNullException("node"); } var value = modelValueProviderFactory.Get(model.GetType()).GetValue(model, Parrot.Infrastructure.ValueType.Property, outputNode.VariableName); return value.ToString(); }
public string Render(AbstractNode node, object documentHost) { var modelValueProviderFactory = _host.DependencyResolver.Resolve<IModelValueProviderFactory>(); if (node == null) { throw new ArgumentNullException("node"); } var outputNode = node as EncodedOutput; if (outputNode == null) { throw new ArgumentNullException("node"); } var value = modelValueProviderFactory.Get(documentHost.GetType()).GetValue(documentHost, Parrot.Infrastructure.ValueType.Property, outputNode.VariableName); //html encode this! return System.Net.WebUtility.HtmlEncode(value.ToString()); }
public string Render(AbstractNode node, object model) { //assert we have a blocknode if (node == null) { throw new ArgumentNullException("node"); } var docTypeNode = node as BlockNode; if (docTypeNode == null || !docTypeNode.BlockName.Equals("doctype", StringComparison.OrdinalIgnoreCase)) { throw new InvalidCastException("node was not a docType element"); } var value = "html"; //default value of "html" var parameter = docTypeNode.Parameters != null ? docTypeNode.Parameters.FirstOrDefault() : null; if (parameter != null) { value = parameter.Value; } return string.Format("<!DOCTYPE {0}>", value); }
public string Render(AbstractNode node, object model) { var modelValueProviderFactory = _host.DependencyResolver.Resolve<IModelValueProviderFactory>(); if (node == null) { throw new ArgumentNullException("node"); } var blockNode = node as Statement; //this tag can't have any children if (blockNode.Children.Any()) { throw new Exception("Block can't have any children"); } var localModel = model; TagBuilder tag = new TagBuilder("input"); foreach (var attribute in blockNode.Attributes) { object attributeValue = model; if (attributeValue != null) { attributeValue = modelValueProviderFactory.Get(model.GetType()).GetValue(model, attribute.ValueType, attribute.Value); } else { attributeValue = modelValueProviderFactory.Get(typeof(object)).GetValue(model, attribute.ValueType, attribute.Value); } if (attribute.Key == "class") { tag.AddCssClass((string)attributeValue); } else { Func<object, Parrot.Infrastructure.ValueType, bool> noOutput = (a, v) => { if (a is bool && !(bool) attributeValue) { return true; } if (attributeValue == null && v == Parrot.Infrastructure.ValueType.Keyword) { return true; } return false; }; if (attributeValue is bool && (bool)attributeValue) { tag.MergeAttribute(attribute.Key, attribute.Key, true); } else if (noOutput(attributeValue, attribute.ValueType)) { //checked=false should not output the checked attribute //checked=null should not output the checked attribute } else { tag.MergeAttribute(attribute.Key, (string)attributeValue, true); } } } //check and see if there's a parameter and assign it to value if (blockNode.Parameters != null && blockNode.Parameters.Count == 1) { //grab only the first var parameter = blockNode.Parameters[0]; string value = parameter.Value; tag.MergeAttribute("value", value, true); } return tag.ToString(TagRenderMode.SelfClosing); }
public virtual string Render(AbstractNode node) { return Render(node, null); }
public string Render(AbstractNode node, object model) { return _renderer(null, model); }
public string Render(AbstractNode node) { return "null"; //throw a null reference exception here? }
public string Render(AbstractNode node, object documentHost) { return documentHost.ToString(); }
public string Render(AbstractNode node) { throw new InvalidOperationException(); }