I'm probably not phrasing this question properly, but hopefully I can get the intention across.
I have an application with three projects. Project 1 is the web-facing part of the application. Project 2 is an API for accessing information. Project 3 is the part which accesses the database to obtain information, and returns that information to the caller.
From Project 1, I call methods contained within objects in Project 3, in order to access / modify information for use on the website. So, for example, from Project 1, I'll call Project3.classes.myObject.getObject(2) to get an instance of myObject based on a database query for objectID 2.
myObject has a whole bunch of attributes which I make use of in Project 1. These attributes are not all necessarily visible on the website, many are used internally within Project 1.
Now, from Project 2, I want to be able to return this information through an API call. So for example, calling the API with /controllers/myObject/2 would also invoke the Project3.classes.myObject.getObject(2). But when I'm calling from Project 2, I would like to restrict the attributes that are returned.
I know I can accomplish this by wrapping the returned object in Project 2, and limiting what is actually returned from the API call in that manner. But, is there any way I can have this be done within Project 3 instead?
I know that when I declare an attribute as "public", it is available to any assembly that calls it, and I know if I make it "internal", it is only available to the containing assembly. Is there any modifier which I can use that says, instead of "any" assembly that calls it, only specific assemblies?
Or am I thinking about this completely the wrong way?
seems like ur talking about adding attribute
[assembly:InternalsVisibleTo(Project1)]
to Project3 AssemblyInfo.cs
Next set all the props which should be visible to Project1 but not to Project2 as internal
.
Having said that, I really don't think it's a good design, although I have seen that used in real world API. The intention was to share some functionality between DLLs of the API while hiding it from 3rd party apps.