示例#1
0
        protected override void Visit(ContentSetChunk chunk)
        {
            string str;

            this.CodeIndent(chunk).WriteLine("Using OutputScope(new System.IO.StringWriter())").AddIndent();
            this.CodeDefault();
            this.PushScope();
            base.Accept(chunk.Body);
            this.CodeHidden();
            switch (chunk.AddType)
            {
            case ContentAddType.InsertBefore:
                str = "{0} = Output.ToString() + {0}";
                break;

            case ContentAddType.AppendAfter:
                str = "{0} = {0} + Output.ToString()";
                break;

            default:
                str = "{0} = Output.ToString()";
                break;
            }
            this._source.WriteFormat(str, new object[] { chunk.Variable }).WriteLine();
            this.PopScope();
            this._source.RemoveIndent().WriteLine("End Using");
            this.CodeDefault();
        }
示例#2
0
        protected override void Visit(ContentSetChunk chunk)
        {
            string str;

            this.CodeIndent(chunk).WriteLine("using(OutputScope(new System.IO.StringWriter()))");
            this.CodeDefault();
            this.AppendOpenBrace();
            base.Accept(chunk.Body);
            this.CodeHidden();
            switch (chunk.AddType)
            {
            case ContentAddType.InsertBefore:
                str = "{0} = Output.ToString() + {0};";
                break;

            case ContentAddType.AppendAfter:
                str = "{0} = {0} + Output.ToString();";
                break;

            default:
                str = "{0} = Output.ToString();";
                break;
            }
            this._source.WriteLine(str, new object[] { chunk.Variable });
            this.AppendCloseBrace();
            this.CodeDefault();
        }
示例#3
0
        protected override void Visit(ContentSetChunk chunk)
        {
            CodeIndent(chunk)
            .WriteLine("Using OutputScope(new System.IO.StringWriter())")
            .AddIndent();
            CodeDefault();

            PushScope();
            Accept(chunk.Body);

            CodeHidden();
            string format;

            switch (chunk.AddType)
            {
            case ContentAddType.AppendAfter:
                format = "{0} = {0} + Output.ToString()";
                break;

            case ContentAddType.InsertBefore:
                format = "{0} = Output.ToString() + {0}";
                break;

            default:
                format = "{0} = Output.ToString()";
                break;
            }
            _source.WriteFormat(format, chunk.Variable).WriteLine();

            PopScope();
            _source.RemoveIndent().WriteLine("End Using");

            CodeDefault();
        }
        protected override void Visit(ContentSetChunk chunk)
        {
            _source.AppendLine("OutputScope(new StringWriter()); {");
            Accept(chunk.Body);
            switch (chunk.AddType)
            {
            case ContentAddType.AppendAfter:
                //format = "{0} = {0} + Output.ToString();";
                _source
                .Append(chunk.Variable)
                .Append(" = ")
                .Append(chunk.Variable)
                .AppendLine(" + Output.toString();");
                break;

            case ContentAddType.InsertBefore:
                //format = "{0} = Output.ToString() + {0};";
                _source
                .Append(chunk.Variable)
                .Append(" = Output.toString() + ")
                .Append(chunk.Variable)
                .AppendLine(";");
                break;

            default:
                //format = "{0} = Output.ToString();";
                _source
                .Append(chunk.Variable)
                .Append(" = Output.toString();");
                break;
            }

            _source.AppendLine("DisposeOutputScope();}");
        }
示例#5
0
        protected override void Visit(ContentSetChunk chunk)
        {
            CodeIndent(chunk).WriteLine("using(OutputScope(new System.IO.StringWriter()))");
            CodeDefault();

            AppendOpenBrace();

            Accept(chunk.Body);

            CodeHidden();
            string format;

            switch (chunk.AddType)
            {
            case ContentAddType.AppendAfter:
                format = "{0} = {0} + Output.ToString();";
                break;

            case ContentAddType.InsertBefore:
                format = "{0} = Output.ToString() + {0};";
                break;

            default:
                format = "{0} = Output.ToString();";
                break;
            }
            _source.WriteLine(format, chunk.Variable);

            AppendCloseBrace();

            CodeDefault();
        }
        protected override void Visit(ContentSetChunk chunk)
        {
            this._source.AppendLine("OutputScope(new StringWriter()); {");
            base.Accept(chunk.Body);
            switch (chunk.AddType)
            {
            case ContentAddType.InsertBefore:
                this._source.Append((string)chunk.Variable).Append(" = Output.toString() + ").Append((string)chunk.Variable).AppendLine(";");
                break;

            case ContentAddType.AppendAfter:
                this._source.Append((string)chunk.Variable).Append(" = ").Append((string)chunk.Variable).AppendLine(" + Output.toString();");
                break;

            default:
                this._source.Append((string)chunk.Variable).Append(" = Output.toString();");
                break;
            }
            this._source.AppendLine("DisposeOutputScope();}");
        }
示例#7
0
        protected override void Visit(ContentSetChunk chunk)
        {
            _source.Write("__using").Write(++_usingDepth).WriteLine("=OutputScopeAdapter(None)");
            Accept(chunk.Body);
            switch (chunk.AddType)
            {
            case ContentAddType.AppendAfter:
                //"{0} = {0} + Output.ToString();";
                _source.Write(chunk.Variable).Write("=").Write(chunk.Variable).WriteLine("+Output.ToString()");
                break;

            case ContentAddType.InsertBefore:
                //"{0} = Output.ToString() + {0};";
                _source.Write(chunk.Variable).Write("=Output.ToString()+").WriteLine(chunk.Variable);
                break;

            default:
                //"{0} = Output.ToString();";
                _source.Write(chunk.Variable).WriteLine("=Output.ToString()");
                break;
            }
            _source.Write("__using").Write(_usingDepth--).WriteLine(".Dispose()");
        }
示例#8
0
        protected override void Visit(ContentSetChunk chunk)
        {
            CodeIndent(chunk).WriteLine("using(OutputScope(new System.IO.StringWriter()))");
            CodeDefault();

            AppendOpenBrace();

            Accept(chunk.Body);

            CodeHidden();
            string format;
            switch (chunk.AddType)
            {
                case ContentAddType.AppendAfter:
                    format = "{0} = {0} + Output.ToString();";
                    break;
                case ContentAddType.InsertBefore:
                    format = "{0} = Output.ToString() + {0};";
                    break;
                default:
                    format = "{0} = Output.ToString();";
                    break;
            }

            _source.WriteLine(format, chunk.Variable);

            AppendCloseBrace();

            CodeDefault();
        }
示例#9
0
 protected override void Visit(ContentSetChunk chunk)
 {
     Accept(chunk.Body);
 }
示例#10
0
        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");
            }
        }
示例#11
0
        protected override void Visit(ContentSetChunk chunk)
        {
            CodeIndent(chunk)
                .WriteLine("Using OutputScope(new System.IO.StringWriter())")
                .AddIndent();
            CodeDefault();

            PushScope();
            Accept(chunk.Body);

            CodeHidden();
            string format;
            switch (chunk.AddType)
            {
                case ContentAddType.AppendAfter:
                    format = "{0} = {0} + Output.ToString()";
                    break;
                case ContentAddType.InsertBefore:
                    format = "{0} = Output.ToString() + {0}";
                    break;
                default:
                    format = "{0} = Output.ToString()";
                    break;
            }

            _source.WriteFormat(format, chunk.Variable).WriteLine();

            PopScope();
            _source.RemoveIndent().WriteLine("End Using");

            CodeDefault();
        }
        protected override void Visit(ContentSetChunk chunk)
        {
            CodeIndent(chunk).AppendLine("using(OutputScope(new System.IO.StringWriter()))");
            CodeDefault();

            PushScope();
            AppendIndent().AppendLine("{");
            Indent += 4;
            Accept(chunk.Body);

            CodeHidden();
            string format;
            switch (chunk.AddType)
            {
                case ContentAddType.AppendAfter:
                    format = "{0} = {0} + Output.ToString();";
                    break;
                case ContentAddType.InsertBefore:
                    format = "{0} = Output.ToString() + {0};";
                    break;
                default:
                    format = "{0} = Output.ToString();";
                    break;
            }
            AppendIndent().AppendFormat(format, chunk.Variable).AppendLine();

            Indent -= 4;
            AppendIndent().AppendLine("}");
            PopScope();

            CodeDefault();
        }
示例#13
0
        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(ContentSetChunk chunk)
        {
            _source.AppendLine("OutputScope(new StringWriter()); {");
            Accept(chunk.Body);
            switch (chunk.AddType)
            {
                case ContentAddType.AppendAfter:
                    //format = "{0} = {0} + Output.ToString();";
                    _source
                        .Append(chunk.Variable)
                        .Append(" = ")
                        .Append(chunk.Variable)
                        .AppendLine(" + Output.toString();");
                    break;
                case ContentAddType.InsertBefore:
                    //format = "{0} = Output.ToString() + {0};";
                    _source
                        .Append(chunk.Variable)
                        .Append(" = Output.toString() + ")
                        .Append(chunk.Variable)
                        .AppendLine(";");
                    break;
                default:
                    //format = "{0} = Output.ToString();";
                     _source
                        .Append(chunk.Variable)
                        .Append(" = Output.toString();");
                    break;
            }

            _source.AppendLine("DisposeOutputScope();}");
        }
 protected override void Visit(ContentSetChunk chunk)
 {
     Accept(chunk.Body);
 }
示例#16
0
 protected abstract void Visit(ContentSetChunk chunk);
 protected abstract void Visit(ContentSetChunk chunk);
示例#18
0
        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");
        }