Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Nested namespaces and CodeDom

Nested namespaces and CodeDom

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
6 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erik Doernenburg
    wrote on last edited by
    #1

    I'm trying (in a nutshell) to generate the following code:

    using System;

    namespace Foo
    {
    namespace Bar
    {
    public class Class1
    {
    }
    }
    }

    My problem is that I can't find a way to add the CodeNamespace object for the Bar namespace to the CodeNamespace object for the Foo namespace. None of the collections available through the properties on CodeNamespace allow another CodeNamespace. Any ideas? erik

    V L J 3 Replies Last reply
    0
    • E Erik Doernenburg

      I'm trying (in a nutshell) to generate the following code:

      using System;

      namespace Foo
      {
      namespace Bar
      {
      public class Class1
      {
      }
      }
      }

      My problem is that I can't find a way to add the CodeNamespace object for the Bar namespace to the CodeNamespace object for the Foo namespace. None of the collections available through the properties on CodeNamespace allow another CodeNamespace. Any ideas? erik

      V Offline
      V Offline
      Vagif Abilov
      wrote on last edited by
      #2

      Unfortunately, it is not supported. Have a look at this article[^]. Unfortunately, current CodeDom implementation looks more like a fun stuff, it has too many limitations. Вагиф Абилов MCP (Visual C++) Oslo, Norway Hex is for sissies. Real men use binary. And the most hardcore types use only zeros - uppercase zeros and lowercase zeros. Tomasz Sowinski

      1 Reply Last reply
      0
      • E Erik Doernenburg

        I'm trying (in a nutshell) to generate the following code:

        using System;

        namespace Foo
        {
        namespace Bar
        {
        public class Class1
        {
        }
        }
        }

        My problem is that I can't find a way to add the CodeNamespace object for the Bar namespace to the CodeNamespace object for the Foo namespace. None of the collections available through the properties on CodeNamespace allow another CodeNamespace. Any ideas? erik

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        I have seen this soooooooooooo many times.... I ask myself what is wrong with passing the namespace string as say "leppie.Win.Controls.WOW.it.works" :rolleyes: WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.

        E 1 Reply Last reply
        0
        • L leppie

          I have seen this soooooooooooo many times.... I ask myself what is wrong with passing the namespace string as say "leppie.Win.Controls.WOW.it.works" :rolleyes: WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.

          E Offline
          E Offline
          Erik Doernenburg
          wrote on last edited by
          #4

          I know about this. However, what I'm really doing is generating source code and for asthetic reasons I want the 'using' statements and some banner comments outside the namespace which is used for the class, e.g.

          // ---------------------------------
          // Copyright (C) 2003 by ....
          // ---------------------------------
          
          using System;
          using System.Xml;
          
          namespace Bookstore.Model
          {
            public Class Author
            {
          

          The easiest way to achieve this would have been to nest the Bookstore.Model namespace into the default namespace, i.e. a namespace without a name, and add the commets and usings to that. See what I mean?

          L 1 Reply Last reply
          0
          • E Erik Doernenburg

            I know about this. However, what I'm really doing is generating source code and for asthetic reasons I want the 'using' statements and some banner comments outside the namespace which is used for the class, e.g.

            // ---------------------------------
            // Copyright (C) 2003 by ....
            // ---------------------------------
            
            using System;
            using System.Xml;
            
            namespace Bookstore.Model
            {
              public Class Author
              {
            

            The easiest way to achieve this would have been to nest the Bookstore.Model namespace into the default namespace, i.e. a namespace without a name, and add the commets and usings to that. See what I mean?

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            Erik Dörnenburg wrote: The easiest way to achieve this would have been to nest the Bookstore.Model namespace into the default namespace, i.e. a namespace without a name, and add the commets and usings to that. See what I mean? So you want the CodeDom to be pretty too? :) Whats wrong with the using statements inside the namespace? I dont really use CodeDom for its code output, but rather to dynamically generate assemblies. WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.

            1 Reply Last reply
            0
            • E Erik Doernenburg

              I'm trying (in a nutshell) to generate the following code:

              using System;

              namespace Foo
              {
              namespace Bar
              {
              public class Class1
              {
              }
              }
              }

              My problem is that I can't find a way to add the CodeNamespace object for the Bar namespace to the CodeNamespace object for the Foo namespace. None of the collections available through the properties on CodeNamespace allow another CodeNamespace. Any ideas? erik

              J Offline
              J Offline
              John Burton
              wrote on last edited by
              #6

              Well I'm not quite sure what you mean but this defines a class called Foo.Bar.Class1 so maybe you can just have a namespace of Foo.Bar

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups