|
-
Sep 27th, 2005, 09:59 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Reference Default Namespace in Class
Hi and thanks for reading.
I'm trying to develop a generic class that uses Imports statements. Right now, the Imports reference the name of a specific project (e.g. "Imports WWRIS.DataAccessLayer" and "Imports WWRIS.Global"), I want to eliminate the "WWRIS" part to make the class truly generic (e.g. "Imports [Project Default Namespace].DataAccessLayer"). Is this possible?
I know I could remove the namespace for a project altogether, but I would prefer not too.
Thanks,
OneSource
-
Sep 27th, 2005, 01:11 PM
#2
Re: Reference Default Namespace in Class
You mean dynamically change the namesapce? Why would the name change? Isn't the project you are referencing going to have the same namespace?
Instead of importing the namespaces just call all the members by the full namespace (i.e. WWRIS.DataAccessLayer.MyMethod)
-
Sep 27th, 2005, 02:46 PM
#3
Thread Starter
Fanatic Member
Edneeis ...
Thanks for your response.
You mean dynamically change the namesapce?
Yes!
Isn't the project you are referencing going to have the same namespace?
Yes, but I want to use the generic class in multiple projects without having to tinker with the namespace every time. Understand?
WWRIS.DataAccessLayer.MyMethod
is specific to the WWRIS project. When I put the class in another project, I don't want to have to update the Import statements in the generic class, because I need to access [Project Default Namespace].DataAccessLayer.MyMethod in whatever project I place the class into.
In short, I don't want to change the Imports statement based on the project that the generic class is used in. I just want to drop in the class and have it get the default namespace of the project and use it with the Imports statement, i.e. [Project Default Namespace].DataAccessLayer.MyMethod. Is this possible?
Thanks...
-
Sep 27th, 2005, 06:54 PM
#4
Re: Reference Default Namespace in Class
I can't give you a 100% iron-clad guarantee but I'm going to say with relative surety that it is not possible, and why would it be? If you were allowed to change the namespace like that then there would be no guarantee that each would contain the same members. If you want to use that library like that then you need to set it up in such a way that it will expect certain types that all the other projects can supply. This sounds like a job for an Interface to me. That way, the generic library can take and return objects that implement certain interfaces and your other projects can implement those interfaces, allowing them all to use the other library.
-
Sep 28th, 2005, 09:30 AM
#5
Thread Starter
Fanatic Member
jmcilhinney ....
Thanks. I didn't know if it was possible and feel even more so that it isn't after reading your reply. I'll look at using an Interfaces to the class.
OneSource
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|