public static string GetCSharpDeclaration(this IDefinition definition, bool includeAttributes = false)
        {
            using (var stringWriter = new StringWriter())
            {
                using (var syntaxWriter = new TextSyntaxWriter(stringWriter))
                {
                    var writer = new CSDeclarationWriter(syntaxWriter, new AttributesFilter(includeAttributes), false, true);

                    var nsp = definition as INamespaceDefinition;
                    var typeDefinition = definition as ITypeDefinition;
                    var member = definition as ITypeDefinitionMember;

                    if (nsp != null)
                        writer.WriteNamespaceDeclaration(nsp);
                    else if (typeDefinition != null)
                        writer.WriteTypeDeclaration(typeDefinition);
                    else if (member != null)
                    {
                        var method = member as IMethodDefinition;
                        if (method != null && method.IsPropertyOrEventAccessor())
                            WriteAccessor(syntaxWriter, method);
                        else
                            writer.WriteMemberDeclaration(member);
                    }
                }

                return stringWriter.ToString();
            }
        }
 private void EnsureTokenWriter()
 {
     if (_tokenWriter == null)
     {
         _tokenizer   = new TokenSyntaxWriter();
         _tokenWriter = new CSDeclarationWriter(_tokenizer, _filter, _forCompilation, _includeFakeAttributes);
     }
 }
 public CSharpWriter(ISyntaxWriter writer, ICciFilter filter, bool apiOnly, bool writeAssemblyAttributes = false)
     : base(filter)
 {
     _syntaxWriter = writer;
     _styleWriter = writer as IStyleSyntaxWriter;
     _declarationWriter = new CSDeclarationWriter(_syntaxWriter, filter, !apiOnly);
     _writeAssemblyAttributes = writeAssemblyAttributes;
 }
        private void EnsureStringWriter()
        {
            if (_stringWriter == null)
            {
                _string = new StringBuilder();
                StringWriter     sw  = new StringWriter(_string);
                TextSyntaxWriter tsw = new TextSyntaxWriter(sw);

                _stringWriter = new CSDeclarationWriter(tsw, _filter, _forCompilation, _includeFakeAttributes);
            }
        }
 private void EnsureTokenWriter()
 {
     if (_tokenWriter == null)
     {
         _tokenizer = new TokenSyntaxWriter();
         _tokenWriter = new CSDeclarationWriter(_tokenizer, _filter, _forCompilation, _includeFakeAttributes);
     }
 }
        private void EnsureStringWriter()
        {
            if (_stringWriter == null)
            {
                _string = new StringBuilder();
                StringWriter sw = new StringWriter(_string);
                TextSyntaxWriter tsw = new TextSyntaxWriter(sw);

                _stringWriter = new CSDeclarationWriter(tsw, _filter, _forCompilation, _includeFakeAttributes);
            }
        }