private NamespaceDeclarationTranslation CreateNewNamespace(string identifier, BaseTypeDeclarationTranslation typeDeclarationTranslation) { NamespaceDeclarationTranslation newNamespaceTranslation = new NamespaceDeclarationTranslation(); newNamespaceTranslation.Name = new IdentifierNameTranslation() { SyntaxString = identifier, Parent = newNamespaceTranslation }; newNamespaceTranslation.Members = new SyntaxListTranslation<MemberDeclarationSyntax, MemberDeclarationTranslation>() { Parent = newNamespaceTranslation }; newNamespaceTranslation.Members.Add(typeDeclarationTranslation); newNamespaceTranslation.IsExport = true; return newNamespaceTranslation; }
public void Apply(BaseTypeDeclarationTranslation typeDeclarationTranslation) { // TODO: only support one level, why do you need nested > 1 level ? TypeDeclarationTranslation outerMemberDeclaration = (TypeDeclarationTranslation)typeDeclarationTranslation.TravelUpNotMe(f => f is TypeDeclarationTranslation); if(outerMemberDeclaration==null) { return; } SyntaxListBaseTranslation syntaxListBaseTranslation = (SyntaxListBaseTranslation)typeDeclarationTranslation.Parent; syntaxListBaseTranslation.Remove(typeDeclarationTranslation); SyntaxListBaseTranslation outerSyntaxListBaseTranslation = (SyntaxListBaseTranslation)outerMemberDeclaration.Parent; var newNamespace = CreateNewNamespace(outerMemberDeclaration.Syntax.Identifier.ToString(), typeDeclarationTranslation); outerSyntaxListBaseTranslation.Add(newNamespace); }