Nested namespaces and CodeDom
-
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
-
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
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
-
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
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.
-
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.
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?
-
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?
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.
-
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
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