/// <inheritdoc/> public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { IType type = typeDeclaration.Annotation <TypeResolveResult>().Type; Formatter.NameSpace = type.Namespace; switch (typeDeclaration.ClassType) { case ClassType.Enum: Formatter.AppendIndented("enum "); break; case ClassType.Interface: Formatter.AppendIndented("class "); break; case ClassType.Struct: Formatter.AppendIndented("struct "); break; default: Formatter.AppendIndented("class "); break; } TypeVisitor.FormatType(type); if (typeDeclaration.ClassType == ClassType.Enum) { OutputEnumValues(typeDeclaration); } else { Formatter.Append(";"); } Formatter.AppendLine(String.Empty); }
/// <summary> /// Header type declaration /// </summary> /// <param name="typeDeclaration">type declaration</param> protected override void HeaderTypeDeclaration(TypeDeclaration typeDeclaration) { HadDefaultConstructor = false; HadConstructor = false; IType type = typeDeclaration.Annotation <TypeResolveResult>().Type; Formatter.NameSpace = type.Namespace; if (!namespaces.ContainsKey(type.Namespace)) { namespaces.Add(type.Namespace, type.Namespace); } OutputEntityType(typeDeclaration); TypeVisitor.FormatType(type); OutputParentage(typeDeclaration, type); Formatter.AddOpenBrace(); if (typeDeclaration.ClassType != ClassType.Struct) { Formatter.AppendIndentedLine("public:"); } foreach (var member in typeDeclaration.Members) { member.AcceptVisitor(this); } if (typeDeclaration.ClassType == ClassType.Struct && HadConstructor && !HadDefaultConstructor) { CreateDefaultConstructor(typeDeclaration); } Formatter.AddCloseBrace(true); }