コード例 #1
0
        public static void WriteStringValue(this ISyntaxWriter writer, StringValueNode node)
        {
            if (node.Block)
            {
                writer.Write("\"\"\"");

                var lines = node.Value
                            .Replace("\"\"\"", "\\\"\"\"")
                            .Replace("\r", string.Empty)
                            .Split('\n');

                foreach (var line in lines)
                {
                    writer.WriteLine();
                    writer.WriteIndent();
                    writer.Write(line);
                }

                writer.WriteLine();
                writer.WriteIndent();
                writer.Write("\"\"\"");
            }
            else
            {
                writer.Write('"');
                WriteEscapeCharacters(writer, node.Value);
                writer.Write('"');
            }
        }
コード例 #2
0
ファイル: CSharpWriter.cs プロジェクト: jkoritzinsky/arcade
        public override void Visit(INamespaceDefinition ns)
        {
            if (ns != null && string.IsNullOrEmpty(ns.Name.Value))
            {
                base.Visit(ns);
            }
            else
            {
                _declarationWriter.WriteDeclaration(ns);

                using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine))
                {
                    var types = ns.GetTypes(this.IncludeForwardedTypes);
                    if (ConditionalTypeLists != null)
                    {
                        // in the first pass we want all types *except* the ones in ConditionalTypeLists filters
                        // in the second pass we want *only* the types in ConditionalTypeLists filters
                        var firstPass = _currentTypeListFilter == null;
                        types = types.Where(t => ConditionalTypeLists.Any(c => c.Filter.Include(t) == !firstPass));
                    }

                    Visit(types);
                }
            }

            _syntaxWriter.WriteLine();
        }
コード例 #3
0
 public static void WriteLine(this ISyntaxWriter writer, bool force)
 {
     if (force) // Need to make sure the stream isn't empty so that it doesn't ignore the WriteLine
     {
         writer.Write(" ");
     }
     writer.WriteLine();
 }
コード例 #4
0
        public static IDisposable StartBraceBlock(this ISyntaxWriter writer, bool onNewLine)
        {
            if (onNewLine)
            {
                writer.WriteLine();
            }
            else
            {
                writer.WriteSpace();
            }

            writer.WriteSymbol("{");
            writer.WriteLine();
            writer.IndentLevel++;
            return(new Block(() =>
            {
                writer.IndentLevel--;
                writer.WriteSymbol("}");
                writer.WriteLine();
            }));
        }
コード例 #5
0
        private void VisitDocument(DocumentNode node, ISyntaxWriter writer)
        {
            if (node.Definitions.Count > 0)
            {
                VisitDefinition(node.Definitions[0], writer);

                for (int i = 1; i < node.Definitions.Count; i++)
                {
                    if (_indented)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                    }
                    else
                    {
                        writer.WriteSpace();
                    }

                    VisitDefinition(node.Definitions[i], writer);
                }
            }
        }
コード例 #6
0
        public override void Visit(INamespaceDefinition ns)
        {
            _declarationWriter.WriteDeclaration(ns);

            using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine))
            {
                base.Visit(ns);
            }

            _syntaxWriter.WriteLine();
        }
コード例 #7
0
        public override void Visit(INamespaceDefinition ns)
        {
            if (ns != null && string.IsNullOrEmpty(ns.Name.Value))
            {
                base.Visit(ns);
            }
            else
            {
                _declarationWriter.WriteDeclaration(ns);

                using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine))
                {
                    base.Visit(ns);
                }
            }

            _syntaxWriter.WriteLine();
        }
コード例 #8
0
 public override void Visit(ITypeDefinition type)
 {
     _declarationWriter.WriteDeclaration(type);
     _syntaxWriter.WriteLine();
 }