I'll try to keep this as general as possible, as I'm trying to understand a pattern rather than solve a specific problem.
Suppose I have a web application (A), and I want to make part of its logic and/or structures available through a restricted interface. For example, I may want to enable users to register an account, but only through a AccountManager.RegisterAccount
method rather than by doing a new Account
(which users should not be allowed to call). Such users should be able to register the account, but not necessarily through the web application.
To achieve this, I create a class library (B), with all the base structures and business logic, leaving in the web app project just what relates to the web itself.
However, I can't see how I could release the library B without revealing parts that should be kept hidden from users of that class. The internal
access modifier isn't really my tool here, because it would restrict those parts from the app A too. Instead, I need those parts to be "public" for A (which is a "privileged user" of B), but "non public" for the users of B.
How can I achieve that?