private void VisitVar(SpecialNode specialNode, SpecialNodeInspector inspector) { Frame frame = null; if (!specialNode.Element.IsEmptyElement) { ScopeChunk item = new ScopeChunk { Position = this.Locate(specialNode.Element) }; this.Chunks.Add(item); frame = new Frame(this, item.Body); } AttributeNode attr = inspector.TakeAttribute("type"); Snippets snippets = (attr != null) ? this.AsCode(attr) : "var"; foreach (AttributeNode node2 in inspector.Attributes) { LocalVariableChunk chunk3 = new LocalVariableChunk { Type = snippets, Name = node2.Name, Value = this.AsTextOrientedCode(node2), Position = this.Locate(node2) }; this.Chunks.Add(chunk3); } base.Accept(specialNode.Body); if (frame != null) { frame.Dispose(); } }
protected override void Visit(LocalVariableChunk chunk) { if (Snippets.IsNullOrEmpty(chunk.Value)) { this._source.Append("var ").Append((string)chunk.Name).AppendLine(" = null;"); } else { this._source.Append("var ").Append((string)chunk.Name).Append(" = ").Append((string)chunk.Value).AppendLine(";"); } }
protected override void Visit(LocalVariableChunk chunk) { if (Snippets.IsNullOrEmpty(chunk.Value)) { _source.Append("var ").Append(chunk.Name).AppendLine(" = null;"); } else { _source.Append("var ").Append(chunk.Name).Append(" = ").Append(chunk.Value).AppendLine(";"); } }
protected override void Visit(LocalVariableChunk chunk) { this.DeclareVariable((string)chunk.Name); this.CodeIndent(chunk).WriteCode(chunk.Type).Write(" ").WriteCode(chunk.Name); if (!Snippets.IsNullOrEmpty(chunk.Value)) { this._source.Write(" = ").WriteCode(chunk.Value); } this._source.WriteLine(";"); this.CodeDefault(); }
protected override void Visit(LocalVariableChunk chunk) { _variables.Declare(chunk.Name); var value = chunk.Value; if (Snippets.IsNullOrEmpty(value)) { value = "None"; } _source.Write(chunk.Name).Write("=").WriteLine(value); }
private void VisitSection(SpecialNode node, SpecialNodeInspector inspector) { IList <Chunk> list; if (this.SectionChunks == null) { throw new CompilerException("Section cannot be used at this location", this.Locate(node.Element)); } AttributeNode node2 = inspector.TakeAttribute("name"); if (node2 == null) { throw new CompilerException("Section element must have a name attribute", this.Locate(node.Element)); } if (!this.SectionChunks.TryGetValue(node2.Value, out list)) { list = new List <Chunk>(); this.SectionChunks.Add(node2.Value, list); } ScopeChunk item = new ScopeChunk { Position = this.Locate(inspector.OriginalNode) }; list.Add(item); using (new Frame(this, item.Body)) { foreach (AttributeNode node3 in inspector.Attributes) { LocalVariableChunk chunk2 = new LocalVariableChunk { Name = node3.Name, Value = this.AsCode(node3), Position = this.Locate(node3) }; this.Chunks.Add(chunk2); } base.Accept(inspector.Body); } }
protected override void Visit(LocalVariableChunk chunk) { this.LocalVariableImpl(chunk, chunk.Name, chunk.Type, chunk.Value); }
protected abstract void Visit(LocalVariableChunk chunk);
private void VisitContent(SpecialNodeInspector inspector) { var nameAttr = inspector.TakeAttribute("name"); var varAttr = inspector.TakeAttribute("var"); var defAttr = inspector.TakeAttribute("def"); var setAttr = inspector.TakeAttribute("set"); if (nameAttr != null) { var contentChunk = new ContentChunk { Name = nameAttr.Value, Position = Locate(inspector.OriginalNode) }; Chunks.Add(contentChunk); using (new Frame(this, contentChunk.Body)) Accept(inspector.Body); } else if (varAttr != null || defAttr != null) { var variableChunk = new LocalVariableChunk { Name = AsCode(varAttr ?? defAttr), Type = "string" }; Chunks.Add(variableChunk); var contentSetChunk = new ContentSetChunk { Variable = variableChunk.Name, Position = Locate(inspector.OriginalNode) }; Chunks.Add(contentSetChunk); using (new Frame(this, contentSetChunk.Body)) Accept(inspector.Body); } else if (setAttr != null) { var addAttr = inspector.TakeAttribute("add"); var contentSetChunk = new ContentSetChunk { Variable = AsCode(setAttr), Position = Locate(inspector.OriginalNode) }; if (addAttr != null) { if (addAttr.Value == "before") { contentSetChunk.AddType = ContentAddType.InsertBefore; } else if (addAttr.Value == "after") { contentSetChunk.AddType = ContentAddType.AppendAfter; } else if (addAttr.Value == "replace") { contentSetChunk.AddType = ContentAddType.Replace; } else { throw new CompilerException("add attribute must be 'before', 'after', or 'replace"); } } Chunks.Add(contentSetChunk); using (new Frame(this, contentSetChunk.Body)) Accept(inspector.Body); } else { throw new CompilerException("content element must have name, var, def, or set attribute"); } }
protected override void Visit(LocalVariableChunk chunk) { chunk.Value = Process(chunk, chunk.Value); base.Visit(chunk); }
private void VisitRender(SpecialNode node, SpecialNodeInspector inspector) { AttributeNode node2 = inspector.TakeAttribute("partial"); if (node2 != null) { ScopeChunk chunk = new ScopeChunk { Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(chunk); using (new Frame(this, chunk.Body)) { foreach (AttributeNode node3 in inspector.Attributes) { LocalVariableChunk chunk2 = new LocalVariableChunk { Name = node3.Name, Value = this.AsTextOrientedCode(node3), Position = this.Locate(node3) }; this.Chunks.Add(chunk2); } RenderPartialChunk chunk3 = new RenderPartialChunk { Name = node2.Value, Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(chunk3); using (new Frame(this, chunk3.Body, chunk3.Sections)) { base.Accept(inspector.Body); } return; } } AttributeNode node4 = inspector.TakeAttribute("segment"); if (base.Context.ParseSectionTagAsSegment && (node4 == null)) { node4 = inspector.TakeAttribute("section"); } string str = null; if (node4 != null) { str = node4.Value; } ScopeChunk item = new ScopeChunk { Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(item); using (new Frame(this, item.Body)) { foreach (AttributeNode node5 in inspector.Attributes) { LocalVariableChunk chunk7 = new LocalVariableChunk { Name = node5.Name, Value = this.AsTextOrientedCode(node5), Position = this.Locate(node5) }; this.Chunks.Add(chunk7); } RenderSectionChunk chunk8 = new RenderSectionChunk { Name = str }; this.Chunks.Add(chunk8); using (new Frame(this, chunk8.Default)) { base.Accept(inspector.Body); } } }
private void VisitContent(SpecialNodeInspector inspector) { var nameAttr = inspector.TakeAttribute("name"); var varAttr = inspector.TakeAttribute("var"); var defAttr = inspector.TakeAttribute("def"); var setAttr = inspector.TakeAttribute("set"); if (nameAttr != null) { var contentChunk = new ContentChunk { Name = nameAttr.Value, Position = Locate(inspector.OriginalNode) }; Chunks.Add(contentChunk); using (new Frame(this, contentChunk.Body)) Accept(inspector.Body); } else if (varAttr != null || defAttr != null) { var variableChunk = new LocalVariableChunk { Name = AsCode(varAttr ?? defAttr), Type = "string" }; Chunks.Add(variableChunk); var contentSetChunk = new ContentSetChunk { Variable = variableChunk.Name, Position = Locate(inspector.OriginalNode) }; Chunks.Add(contentSetChunk); using (new Frame(this, contentSetChunk.Body)) Accept(inspector.Body); } else if (setAttr != null) { var addAttr = inspector.TakeAttribute("add"); var contentSetChunk = new ContentSetChunk { Variable = AsCode(setAttr), Position = Locate(inspector.OriginalNode) }; if (addAttr != null) { if (addAttr.Value == "before") contentSetChunk.AddType = ContentAddType.InsertBefore; else if (addAttr.Value == "after") contentSetChunk.AddType = ContentAddType.AppendAfter; else if (addAttr.Value == "replace") contentSetChunk.AddType = ContentAddType.Replace; else throw new CompilerException("add attribute must be 'before', 'after', or 'replace"); } Chunks.Add(contentSetChunk); using (new Frame(this, contentSetChunk.Body)) Accept(inspector.Body); } else { throw new CompilerException("content element must have name, var, def, or set attribute"); } }
protected override void Visit(LocalVariableChunk chunk) { Examine(chunk.Value); }
protected override void Visit(LocalVariableChunk chunk) { }
private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector) { AttributeNode node = inspector.TakeAttribute("file"); if (node != null) { ScopeChunk item = new ScopeChunk { Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(item); using (new Frame(this, item.Body)) { foreach (AttributeNode node2 in inspector.Attributes) { LocalVariableChunk chunk2 = new LocalVariableChunk { Name = node2.Name, Value = this.AsTextOrientedCode(node2), Position = this.Locate(node2) }; this.Chunks.Add(chunk2); } RenderPartialChunk chunk3 = new RenderPartialChunk { Name = node.Value, Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(chunk3); using (new Frame(this, chunk3.Body, chunk3.Sections)) { base.Accept(inspector.Body); } return; } } AttributeNode node3 = inspector.TakeAttribute("content"); AttributeNode attr = inspector.TakeAttribute("namespace"); AttributeNode node5 = inspector.TakeAttribute("assembly"); AttributeNode node6 = inspector.TakeAttribute("import"); AttributeNode node7 = inspector.TakeAttribute("master"); AttributeNode node8 = inspector.TakeAttribute("pageBaseType"); if (node3 != null) { UseContentChunk chunk6 = new UseContentChunk { Name = node3.Value, Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(chunk6); using (new Frame(this, chunk6.Default)) { base.Accept(specialNode.Body); return; } } if ((attr != null) || (node5 != null)) { if (attr != null) { UseNamespaceChunk chunk = new UseNamespaceChunk { Namespace = this.AsCode(attr) }; this.AddUnordered(chunk); } if (node5 != null) { UseAssemblyChunk chunk10 = new UseAssemblyChunk { Assembly = node5.Value }; this.AddUnordered(chunk10); } } else if (node6 != null) { UseImportChunk chunk12 = new UseImportChunk { Name = node6.Value }; this.AddUnordered(chunk12); } else if (node7 != null) { UseMasterChunk chunk14 = new UseMasterChunk { Name = node7.Value }; this.AddUnordered(chunk14); } else { if (node8 == null) { throw new CompilerException("Special node use had no understandable attributes"); } PageBaseTypeChunk chunk16 = new PageBaseTypeChunk { BaseClass = this.AsCode(node8) }; this.AddUnordered(chunk16); } }
protected override void Visit(LocalVariableChunk chunk) { chunk.Value = this.Process(chunk, chunk.Value); base.Visit(chunk); }
protected override void Visit(LocalVariableChunk chunk) { DeclareVariable(chunk.Name); CodeIndent(chunk).WriteCode(chunk.Type).Write(" ").WriteCode(chunk.Name); if (!Snippets.IsNullOrEmpty(chunk.Value)) { _source.Write(" = ").WriteCode(chunk.Value); } _source.WriteLine(";"); CodeDefault(); }
protected override void Visit(LocalVariableChunk chunk) { LocalVariableImpl(chunk, chunk.Name, chunk.Type, chunk.Value); }
protected override void Visit(AttributeNode attributeNode) { List <Node> priorNodes = new List <Node>(); List <Node> source = new List <Node>(); foreach (Node node in attributeNode.Nodes) { if (node is ConditionNode) { ConditionNode condition = (ConditionNode)node; MovePriorNodesUnderCondition(condition, priorNodes); source.AddRange(priorNodes); source.Add(condition); priorNodes.Clear(); } else { priorNodes.Add(node); } } source.AddRange(priorNodes); if (!source.All <Node>(node => (node is ConditionNode)) || !source.Any <Node>()) { this.AddLiteral(string.Format(" {0}={1}", attributeNode.Name, attributeNode.QuotChar)); foreach (Node node3 in source) { base.Accept(node3); } this.AddLiteral(attributeNode.QuotChar.ToString()); } else { ScopeChunk item = new ScopeChunk(); LocalVariableChunk chunk3 = new LocalVariableChunk { Name = "__just__once__", Value = new Snippets("0") }; item.Body.Add(chunk3); ConditionalChunk chunk4 = new ConditionalChunk { Type = ConditionalType.If, Condition = new Snippets("__just__once__ < 1") }; this._sendAttributeOnce = chunk4; SendLiteralChunk chunk5 = new SendLiteralChunk { Text = " " + attributeNode.Name + "=\"" }; this._sendAttributeOnce.Body.Add(chunk5); AssignVariableChunk chunk6 = new AssignVariableChunk { Name = "__just__once__", Value = "1" }; this._sendAttributeIncrement = chunk6; this.Chunks.Add(item); using (new Frame(this, item.Body)) { foreach (Node node4 in source) { base.Accept(node4); } } this._sendAttributeOnce = null; this._sendAttributeIncrement = null; ConditionalChunk chunk2 = new ConditionalChunk { Type = ConditionalType.If, Condition = new Snippets("__just__once__ > 0") }; item.Body.Add(chunk2); SendLiteralChunk chunk8 = new SendLiteralChunk { Text = "\"" }; chunk2.Body.Add(chunk8); } }
private void VisitContent(SpecialNodeInspector inspector) { AttributeNode node = inspector.TakeAttribute("name"); AttributeNode node2 = inspector.TakeAttribute("var"); AttributeNode node3 = inspector.TakeAttribute("def"); AttributeNode attr = inspector.TakeAttribute("set"); if (node != null) { ContentChunk item = new ContentChunk { Name = node.Value, Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(item); using (new Frame(this, item.Body)) { base.Accept(inspector.Body); return; } } if ((node2 != null) || (node3 != null)) { LocalVariableChunk chunk3 = new LocalVariableChunk { Name = this.AsCode(node2 ?? node3), Type = "string" }; this.Chunks.Add(chunk3); ContentSetChunk chunk4 = new ContentSetChunk { Variable = chunk3.Name, Position = this.Locate(inspector.OriginalNode) }; this.Chunks.Add(chunk4); using (new Frame(this, chunk4.Body)) { base.Accept(inspector.Body); return; } } if (attr != null) { AttributeNode node5 = inspector.TakeAttribute("add"); ContentSetChunk chunk7 = new ContentSetChunk { Variable = this.AsCode(attr), Position = this.Locate(inspector.OriginalNode) }; if (node5 != null) { if (node5.Value != "before") { if (node5.Value != "after") { if (node5.Value != "replace") { throw new CompilerException("add attribute must be 'before', 'after', or 'replace"); } chunk7.AddType = ContentAddType.Replace; } else { chunk7.AddType = ContentAddType.AppendAfter; } } else { chunk7.AddType = ContentAddType.InsertBefore; } } this.Chunks.Add(chunk7); using (new Frame(this, chunk7.Body)) { base.Accept(inspector.Body); return; } } throw new CompilerException("content element must have name, var, def, or set attribute"); }