protected override void Visit(UseContentChunk chunk)
 {
     this._source.Append("if (Content['").Append(chunk.Name).AppendLine("']) {");
     this._source.Append("Output.Write(Content['").Append(chunk.Name).AppendLine("']);}");
     if (chunk.Default.Count != 0)
     {
         this._source.AppendLine("else {");
         base.Accept(chunk.Default);
         this._source.AppendLine("}");
     }
 }
예제 #2
0
 protected override void Visit(UseContentChunk chunk)
 {
     this.CodeIndent(chunk).Write("If Content.ContainsKey(\"").Write(chunk.Name).WriteLine("\") Then").AddIndent().Write("Global.Spark.Spool.TextWriterExtensions.WriteTo(Content(\"").Write(chunk.Name).WriteLine("\"), Output)").RemoveIndent();
     if (chunk.Default.Any <Chunk>())
     {
         this._source.WriteLine("Else").AddIndent();
         this.PushScope();
         base.Accept(chunk.Default);
         this.PopScope();
         this._source.RemoveIndent();
     }
     this._source.WriteLine("End If");
 }
예제 #3
0
 protected override void Visit(UseContentChunk chunk)
 {
     _source.Write("if Content.ContainsKey(\"").Write(chunk.Name).WriteLine("\"):");
     _source.Indent++;
     _source.Write("OutputWriteAdapter(Content[\"").Write(chunk.Name).WriteLine("\"])");
     _source.Indent--;
     if (chunk.Default.Count != 0)
     {
         _source.WriteLine("else:");
         _source.Indent++;
         Accept(chunk.Default);
         _source.WriteLine("pass");
         _source.Indent--;
     }
 }
예제 #4
0
 protected override void Visit(UseContentChunk chunk)
 {
     _source.Write("if content.contains_key(\"").Write(chunk.Name).WriteLine("\")");
     _source.Indent++;
     _source.Write("output_write_adapter content.get_Item(\"").Write(chunk.Name).WriteLine("\")");
     _source.Indent--;
     if (chunk.Default.Count != 0)
     {
         _source.WriteLine("else");
         _source.Indent++;
         Accept(chunk.Default);
         _source.Indent--;
     }
     _source.WriteLine("end");
 }
예제 #5
0
 protected override void Visit(UseContentChunk chunk)
 {
     this.CodeIndent(chunk).WriteLine(string.Format("if (Content.ContainsKey(\"{0}\"))", chunk.Name));
     this.CodeHidden();
     this.AppendOpenBrace();
     this._source.WriteFormat("global::Spark.Spool.TextWriterExtensions.WriteTo(Content[\"{0}\"], Output);", new object[] { chunk.Name });
     this.AppendCloseBrace();
     if (chunk.Default.Count != 0)
     {
         this._source.WriteLine("else");
         this.AppendOpenBrace();
         base.Accept(chunk.Default);
         this.AppendCloseBrace();
     }
     this.CodeDefault();
 }
 protected abstract void Visit(UseContentChunk chunk);
예제 #7
0
        protected override void Visit(UseContentChunk chunk)
        {
            CodeIndent(chunk).WriteLine(string.Format("if (Content.ContainsKey(\"{0}\"))", chunk.Name));
            CodeHidden();
            AppendOpenBrace();
            _source.WriteFormat("global::Spark.Spool.TextWriterExtensions.WriteTo(Content[\"{0}\"], Output);", chunk.Name);
            AppendCloseBrace();

            if (chunk.Default.Count != 0)
            {
                _source.WriteLine("else");
                AppendOpenBrace();
                Accept(chunk.Default);
                AppendCloseBrace();
            }

            CodeDefault();
        }
예제 #8
0
 protected override void Visit(UseContentChunk chunk)
 {
     Accept(chunk.Default);
 }
예제 #9
0
        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var file = inspector.TakeAttribute("file");
            if (file != null)
            {
                var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                    }

                    var useFileChunk = new RenderPartialChunk { Name = file.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useFileChunk);
                    using (new Frame(this, useFileChunk.Body, useFileChunk.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var contentAttr = inspector.TakeAttribute("content");
                var namespaceAttr = inspector.TakeAttribute("namespace");
                var assemblyAttr = inspector.TakeAttribute("assembly");
                var importAttr = inspector.TakeAttribute("import");
                var masterAttr = inspector.TakeAttribute("master");
                var pageBaseTypeAttr = inspector.TakeAttribute("pageBaseType");

                if (contentAttr != null)
                {
                    var useContentChunk = new UseContentChunk { Name = contentAttr.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useContentChunk);
                    using (new Frame(this, useContentChunk.Default))
                    {
                        Accept(specialNode.Body);
                    }
                }
                else if (namespaceAttr != null || assemblyAttr != null)
                {
                    if (namespaceAttr != null)
                    {
                        var useNamespaceChunk = new UseNamespaceChunk { Namespace = AsCode(namespaceAttr) };
                        AddUnordered(useNamespaceChunk);
                    }

                    if (assemblyAttr != null)
                    {
                        var useAssemblyChunk = new UseAssemblyChunk { Assembly = assemblyAttr.Value };
                        AddUnordered(useAssemblyChunk);
                    }
                }
                else if (importAttr != null)
                {
                    var useImportChunk = new UseImportChunk { Name = importAttr.Value };
                    AddUnordered(useImportChunk);
                }
                else if (masterAttr != null)
                {
                    var useMasterChunk = new UseMasterChunk { Name = masterAttr.Value };
                    AddUnordered(useMasterChunk);
                }
                else if (pageBaseTypeAttr != null)
                {
                    var usePageBaseTypeChunk = new PageBaseTypeChunk { BaseClass = AsCode(pageBaseTypeAttr) };
                    AddUnordered(usePageBaseTypeChunk);
                }
                else
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
            }
        }
예제 #10
0
        protected override void Visit(UseContentChunk chunk)
        {
            CodeIndent(chunk)
                .Write("If Content.ContainsKey(\"")
                .Write(chunk.Name)
                .WriteLine("\") Then").AddIndent()
                .Write("Global.Spark.Spool.TextWriterExtensions.WriteTo(Content(\"")
                .Write(chunk.Name)
                .WriteLine("\"), Output)").RemoveIndent();

            if (chunk.Default.Any())
            {
                _source
                    .WriteLine("Else").AddIndent();
                PushScope();
                Accept(chunk.Default);
                PopScope();
                _source.RemoveIndent();
            }

            _source.WriteLine("End If");
        }
예제 #11
0
        protected override void Visit(UseContentChunk chunk)
        {
            CodeIndent(chunk).AppendLine(string.Format("if (Content.ContainsKey(\"{0}\"))", chunk.Name));
            CodeHidden();
            PushScope();
            AppendIndent().AppendLine("{");
            _source.Append(' ', Indent + 4).AppendLine(string.Format("global::Spark.Spool.TextWriterExtensions.WriteTo(Content[\"{0}\"], Output);", chunk.Name));
            AppendIndent().AppendLine("}");
            PopScope();

            if (chunk.Default.Count != 0)
            {
                AppendIndent().AppendLine("else");
                PushScope();
                AppendIndent().AppendLine("{");
                Indent += 4;
                Accept(chunk.Default);
                Indent -= 4;
                AppendIndent().AppendLine("}");
                PopScope();
            }
            CodeDefault();
        }
예제 #12
0
 protected abstract void Visit(UseContentChunk chunk);
예제 #13
0
        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var file = inspector.TakeAttribute("file");

            if (file != null)
            {
                var scope = new ScopeChunk {
                    Position = Locate(inspector.OriginalNode)
                };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk {
                            Name = attr.Name, Value = AsCode(attr), Position = Locate(attr)
                        });
                    }

                    var useFileChunk = new RenderPartialChunk {
                        Name = file.Value, Position = Locate(inspector.OriginalNode)
                    };
                    Chunks.Add(useFileChunk);
                    using (new Frame(this, useFileChunk.Body, useFileChunk.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var contentAttr      = inspector.TakeAttribute("content");
                var namespaceAttr    = inspector.TakeAttribute("namespace");
                var assemblyAttr     = inspector.TakeAttribute("assembly");
                var importAttr       = inspector.TakeAttribute("import");
                var masterAttr       = inspector.TakeAttribute("master");
                var pageBaseTypeAttr = inspector.TakeAttribute("pageBaseType");

                if (contentAttr != null)
                {
                    var useContentChunk = new UseContentChunk {
                        Name = contentAttr.Value, Position = Locate(inspector.OriginalNode)
                    };
                    Chunks.Add(useContentChunk);
                    using (new Frame(this, useContentChunk.Default))
                    {
                        Accept(specialNode.Body);
                    }
                }
                else if (namespaceAttr != null || assemblyAttr != null)
                {
                    if (namespaceAttr != null)
                    {
                        var useNamespaceChunk = new UseNamespaceChunk {
                            Namespace = AsCode(namespaceAttr)
                        };
                        AddUnordered(useNamespaceChunk);
                    }
                    if (assemblyAttr != null)
                    {
                        var useAssemblyChunk = new UseAssemblyChunk {
                            Assembly = assemblyAttr.Value
                        };
                        AddUnordered(useAssemblyChunk);
                    }
                }
                else if (importAttr != null)
                {
                    var useImportChunk = new UseImportChunk {
                        Name = importAttr.Value
                    };
                    AddUnordered(useImportChunk);
                }
                else if (masterAttr != null)
                {
                    var useMasterChunk = new UseMasterChunk {
                        Name = masterAttr.Value
                    };
                    AddUnordered(useMasterChunk);
                }
                else if (pageBaseTypeAttr != null)
                {
                    var usePageBaseTypeChunk = new PageBaseTypeChunk {
                        BaseClass = AsCode(pageBaseTypeAttr)
                    };
                    AddUnordered(usePageBaseTypeChunk);
                }
                else
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
            }
        }
 protected override void Visit(UseContentChunk chunk)
 {
     _source.Append("if (Content['").Append(chunk.Name).AppendLine("']) {");
     _source.Append("Output.Write(Content['").Append(chunk.Name).AppendLine("']);}");
     if (chunk.Default.Count != 0)
     {
         _source.AppendLine("else {");
         Accept(chunk.Default);
         _source.AppendLine("}");
     }
 }
 protected override void Visit(UseContentChunk chunk)
 {
     Accept(chunk.Default);
 }
예제 #16
0
        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);
            }
        }