I have a class library project. In this project i have some folders to seperate the logic.
Lets say i have a DAL library and within DAL i have IDAL, DALFactory and SQLServerDAL.
Now when i give DAL dll to an other programmer, he can use all of the subDlls. Suppose that i dont want him to use SQLServerDal but others. How can i encapsulate SQLServerDAL so that noone can realize it exists.
Thanks.
EDIT:
More spesically:
using DAL; // it can be written
using DAL.IDAL; // it can be written
using DAL.DALFactory; // it can be written
using DAL.SQLServerDAL; // it dont want to allow anyone write that
This is impossible to do with namespaces, because they don’t exist on the metadata level. Either make all classes in namespace SQLServerDAL internal, as suggested by others, or make SQLServerDAL a static internal class instead of a namespace. In this approach classes inside SQLServerDAL will become nested classes, and will be inaccessible from outside your DAL assembly:
However, if you use reflection or code generation, you may have problems if the libraries you are using do not support nested classes properly.