public static NamespaceUnit GetNamespace(string fullName, bool create = true) { var @namespace = namespaces.GetValue(fullName); if (@namespace == null && create) { @namespace = new NamespaceUnit(fullName, null); } return(@namespace); }
public static SyntaxTree NamespaceUnitToSyntaxTree(NamespaceUnit unit) { var namespaceDeclaration = unit.NamespaceDeclaration; var usings = SyntaxFactory.List(unit.Usings); var compilationUnit = SyntaxFactory.CompilationUnit() .AddMembers(namespaceDeclaration) .WithUsings(usings); return(SyntaxFactory.SyntaxTree(compilationUnit)); }
public ClassUnit(Type type, ClassUnit parent = null) { Debug.Assert(type != null); Type = type; Namespace = CompilationUnit.GetNamespace(type.Namespace); if (parent != null) { Parent = parent; } else { Parent = Namespace; } classes.Add(type, this); }