Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming the Namespace

I am having an issue trying to figure out how to appropriately name my namespace. My namespace is currently:

<CompanyName>.<ProductName>.Configuration

However, using "Configuration" conflicts with:

System.Configuration

To make matters worse, I also have a class called ConfigurationManager. I know I could change it to something like:

<CompanyName>.<ProductName>.<ProductName>Configuration

but that seems redundant. Any ideas?

EDIT: Also, I'm aware when calling either class I can fully qualify the calling code but the frequency that the classes in the System.Configuration namespace and <CompanyName>.<ProductName>.Configuration namespace will be used would make for ugly code.

EDIT2: Providing specifics:

Using statements:

using System.Configuration;
using SummitConfiguration = SST.Summit.Configuration;

Problem Line Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);

Error Message 'SST.Summit.Configuration' is a 'namespace' but it is used like a 'type' (for problem line above)

like image 201
Blake Blackwell Avatar asked Dec 10 '22 18:12

Blake Blackwell


2 Answers

Typically, in cases like this, I leave the Configuration namespace, and use an alias for accessing my namespace (instead of fully qualifying). For example:

using System.Configuration;
using PC = MyCompany.MyProduct.Configuration;

// ...

string configValue = PC.ConfigurationManager.GetValue("Foo");
like image 89
Reed Copsey Avatar answered Feb 22 '23 03:02

Reed Copsey


What about doing something like this:

using System.Configuration;
using MyCompany.MyProduct.ProdConfig

or

using System.Configuration;
using MyCompany.MyProduct.Config
like image 38
Michael Brown Avatar answered Feb 22 '23 02:02

Michael Brown