Example #1
0
        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);
        }
Example #2
0
        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));
        }
Example #3
0
 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);
 }