private void ResolveFromParent(DothtmlNode parentNode) { foreach (var childNode in parentNode.EnumerateChildNodes() ) { childNode.ParentNode = parentNode; } }
private IAbstractControl ProcessHtmlComment(DothtmlNode node, IDataContextStack dataContext, DotHtmlCommentNode commentNode) { var text = commentNode.IsServerSide ? "" : "<!--" + commentNode.Value + "-->"; var literal = treeBuilder.BuildControl(rawLiteralMetadata.Value, node, dataContext); literal.ConstructorParameters = new object[] { text, commentNode.Value, true }; return(literal); }
public static void CheckForErrors(DothtmlNode node) { foreach (var n in node.EnumerateNodes()) { if (n.HasNodeErrors) { throw new DotvvmCompilationException(string.Join(", ", n.NodeErrors), n.Tokens); } } }
public ResolvedTreeRoot(ControlResolverMetadata metadata, DothtmlNode node, DataContextStack dataContext, IReadOnlyDictionary <string, IReadOnlyList <IAbstractDirective> > directives) : base(metadata, node, dataContext) { Directives = directives.ToDictionary(d => d.Key, d => d.Value.ToList()); foreach (var ds in Directives.Values) { foreach (var d in ds) { ((ResolvedDirective)d).Parent = this; } } }
private IAbstractControl ProcessBindingInText(DothtmlNode node, IDataContextStack dataContext) { var bindingNode = (DothtmlBindingNode)node; var literal = treeBuilder.BuildControl(literalMetadata.Value, node, dataContext); var textBinding = ProcessBinding(bindingNode, dataContext); var textProperty = treeBuilder.BuildPropertyBinding(Literal.TextProperty, textBinding, null); treeBuilder.SetProperty(literal, textProperty); var renderSpanElement = treeBuilder.BuildPropertyValue(Literal.RenderSpanElementProperty, false, null); treeBuilder.SetProperty(literal, renderSpanElement); return(literal); }
private IAbstractControl ProcessText(DothtmlNode node, IControlResolverMetadata parentMetadata, IDataContextStack dataContext, DothtmlLiteralNode literalNode) { var whitespace = string.IsNullOrWhiteSpace(literalNode.Value); string text; if (literalNode.Escape) { text = WebUtility.HtmlEncode(literalNode.Value); } else { text = literalNode.Value; } var literal = treeBuilder.BuildControl(rawLiteralMetadata.Value, node, dataContext); literal.ConstructorParameters = new object[] { text, literalNode.Value, whitespace }; return(literal); }
public ResolvedContentNode(ControlResolverMetadata metadata, DothtmlNode node, DataContextStack dataContext) : this(metadata, node, new List <ResolvedControl>(), dataContext) { }
protected virtual bool LogError(Exception exception, DothtmlNode node) { return(false); }
/// <summary> /// Processes the parser node and builds a control. /// </summary> public IAbstractControl ProcessNode(IAbstractTreeNode parent, DothtmlNode node, IControlResolverMetadata parentMetadata, IDataContextStack dataContext) { try { if (node is DothtmlBindingNode) { // binding in text EnsureContentAllowed(parentMetadata, node); return(ProcessBindingInText(node, dataContext)); } else if (node is DotHtmlCommentNode) { // HTML comment var commentNode = node as DotHtmlCommentNode; return(ProcessHtmlComment(node, dataContext, commentNode)); } else if (node is DothtmlLiteralNode) { // text content var literalNode = (DothtmlLiteralNode)node; return(ProcessText(node, parentMetadata, dataContext, literalNode)); } else if (node is DothtmlElementNode) { // HTML element EnsureContentAllowed(parentMetadata, node); var element = (DothtmlElementNode)node; return(ProcessObjectElement(element, dataContext)); } else { throw new NotSupportedException($"The node of type '{node.GetType()}' is not supported!"); } } catch (DotvvmCompilationException ex) { if (ex.Tokens == null) { ex.Tokens = node.Tokens; ex.ColumnNumber = node.Tokens.First().ColumnNumber; ex.LineNumber = node.Tokens.First().LineNumber; } if (!LogError(ex, node)) { throw; } else { return(null); } } catch (Exception ex) { if (!LogError(ex, node)) { throw new DotvvmCompilationException("", ex, node.Tokens); } else { return(null); } } }
public ResolvedTreeRoot(ControlResolverMetadata metadata, DothtmlNode node, DataContextStack dataContext, IReadOnlyDictionary <string, IReadOnlyList <IAbstractDirective> > directives) : base(metadata, node, dataContext) { Directives = directives.ToDictionary(d => d.Key, d => d.Value.ToList()); directives.SelectMany(d => d.Value).ToList().ForEach(d => { ((ResolvedDirective)d).Parent = this; }); }
public ResolvedTreeRoot(ControlResolverMetadata metadata, DothtmlNode node, DataContextStack dataContext) : base(metadata, node, dataContext) { }
public IAbstractPropertyValue BuildPropertyValue(IPropertyDescriptor property, object value, DothtmlNode sourceNode) { return(new ResolvedPropertyValue((DotvvmProperty)property, value) { DothtmlNode = sourceNode }); }
public IAbstractControl BuildControl(IControlResolverMetadata metadata, DothtmlNode node, IDataContextStack dataContext) { return(new ResolvedControl((ControlResolverMetadata)metadata, node, (DataContextStack)dataContext)); }
private ResolvedControl ProcessNode(DothtmlNode node, ControlResolverMetadata parentMetadata, DataContextStack dataContext) { try { if (node is DothtmlBindingNode) { EnsureContentAllowed(parentMetadata); // binding in text var binding = (DothtmlBindingNode)node; var literal = new ResolvedControl(controlResolver.ResolveControl(typeof(Literal)), node, dataContext); literal.SetProperty(new ResolvedPropertyBinding(Literal.TextProperty, ProcessBinding(binding, dataContext))); literal.SetProperty(new ResolvedPropertyValue(Literal.RenderSpanElementProperty, false)); return(literal); } else if (node is DotHtmlCommentNode) { var commentNode = node as DotHtmlCommentNode; string text = commentNode.IsServerSide ? "" : "<!--" + commentNode.Value + "-->"; var literal = new ResolvedControl(controlResolver.ResolveControl(typeof(RawLiteral)), node, dataContext); literal.ContructorParameters = new object[] { text, commentNode.Value, true }; return(literal); } else if (node is DothtmlLiteralNode) { var literalNode = ((DothtmlLiteralNode)node); // text content var whitespace = string.IsNullOrWhiteSpace(literalNode.Value); if (!whitespace) { EnsureContentAllowed(parentMetadata); } string text; if (literalNode.Escape) { text = WebUtility.HtmlEncode(literalNode.Value); } else { text = literalNode.Value; } var literal = new ResolvedControl(controlResolver.ResolveControl(typeof(RawLiteral)), node, dataContext); literal.ContructorParameters = new object[] { text, literalNode.Value, whitespace }; return(literal); } else if (node is DothtmlElementNode) { // HTML element var element = (DothtmlElementNode)node; EnsureContentAllowed(parentMetadata); // the element is the content return(ProcessObjectElement(element, dataContext)); } else { throw new NotSupportedException($"The node of type '{node.GetType()}' is not supported!"); } } catch (DotvvmCompilationException ex) { if (ex.Tokens == null) { ex.Tokens = node.Tokens; ex.ColumnNumber = node.Tokens.First().ColumnNumber; ex.LineNumber = node.Tokens.First().LineNumber; } throw; } catch (Exception ex) { throw new DotvvmCompilationException("", ex, node.Tokens); } }
public bool Condition(DothtmlNode node) { return(true); }
public bool Condition(DothtmlNode node) { return true; }