Click here to Skip to main content
15,892,809 members
Articles / Programming Languages / C#

Resolving Symbolic References in a CodeDOM (Part 7)

Rate me:
Please Sign up or sign in to vote.
4.75/5 (6 votes)
2 Dec 2012CDDL12 min read 19.4K   509   14  
Resolving symbolic references in a CodeDOM.
// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php

using System;

namespace Nova.CodeDOM
{
    /// <summary>
    /// This interface is implemented by all code objects that represent namespace declarations
    /// (<see cref="Namespace"/> and <see cref="Alias"/>).
    /// </summary>
    public interface INamespace : INamedCodeObject
    {
        /// <summary>
        /// The parent <see cref="CodeObject"/>.
        /// </summary>
        CodeObject Parent { get; }

        /// <summary>
        /// The full name of the <see cref="Namespace"/>, including any parent namespaces.
        /// </summary>
        string FullName { get; }

        /// <summary>
        /// The dictionary of child types and namespaces in the <see cref="Namespace"/>.
        /// </summary>
        NamespaceTypeDictionary Children { get; }

        /// <summary>
        /// Determines if this <see cref="Namespace"/> is root-level (global or extern alias).
        /// </summary>
        bool IsRootLevel { get; }

        /// <summary>
        /// Determines if this <see cref="Namespace"/> is the project-global namespace.
        /// </summary>
        bool IsGlobal { get; }

        /// <summary>
        /// True if this <see cref="Namespace"/> has <see cref="NamespaceDecl"/> declarations in the current project, otherwise
        /// false (meaning items in the namespace exist only in imported assemblies and projects).
        /// </summary>
        bool HasDeclarationsInProject { get; }

        /// <summary>
        /// Add a child <see cref="Namespace"/> to the <see cref="Namespace"/>.
        /// </summary>
        void Add(Namespace @namespace);

        /// <summary>
        /// Add a <see cref="TypeDecl"/> to the <see cref="Namespace"/>.
        /// </summary>
        void Add(TypeDecl typeDecl);

        /// <summary>
        /// Add a <see cref="Type"/> to the <see cref="Namespace"/>.
        /// </summary>
        void Add(Type type);

        /// <summary>
        /// Remove a child <see cref="Namespace"/> from the <see cref="Namespace"/>.
        /// </summary>
        void Remove(Namespace @namespace);

        /// <summary>
        /// Remove a <see cref="TypeDecl"/> from the <see cref="Namespace"/>.
        /// </summary>
        void Remove(TypeDecl typeDecl);

        /// <summary>
        /// Remove a <see cref="Type"/> from the <see cref="Namespace"/>.
        /// </summary>
        void Remove(Type type);

        /// <summary>
        /// Remove all items from the <see cref="Namespace"/>.
        /// </summary>
        void RemoveAll();

        /// <summary>
        /// Find or create a child <see cref="Namespace"/>, including any missing parent namespaces.
        /// </summary>
        Namespace FindOrCreateChildNamespace(string namespaceName);

        /// <summary>
        /// Find a child <see cref="Namespace"/>, <see cref="Type"/>, or <see cref="TypeDecl"/> with the specified name.
        /// </summary>
        object Find(string name);

        /// <summary>
        /// Parse the specified name into a child <see cref="NamespaceRef"/> or <see cref="TypeRef"/> on the current namespace,
        /// or a <see cref="Dot"/> expression that evaluates to one.
        /// </summary>
        Expression ParseName(string name);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Software Developer (Senior)
United States United States
I've been writing software since the late 70's, currently focusing mainly on C#.NET. I also like to travel around the world, and I own a Chocolate Factory (sadly, none of my employees are oompa loompas).

Comments and Discussions