tags:

views:

64

answers:

2

I have two C#.NET projects in a single solution ModelProject and PluginProject. PlugInProject is a plug-in for another application, and consequently references its API. PlugInProject is used to extract data from the application it plugs into. ModelProject contains the data model of classes that are extracted by PlugInProject.

The extracted data can be used independent of the application or the plug-in, which is why I am keeping PlugInProject separate from ModelProject. I want ModelProject to remain independent of PlugInProject, and the Applications API. Or in other words I want someone to be able to access the extracted data without needing access to PlugInProject, the application, or the application's API.

The problem I'm running into though is PlugInProject needs to be able to create and modify classes in ModelProject. However, I'd prefer to not make these actions public to anyone using ModelProject. The extracted data should effectively be read-only, unless later modified by PlugInProject.

How can I keep these projects separate but give PlugInProject exclusive access to ModelProject? Is this possible?

A: 

Can you use inheritance to extend classes in ModelProject?

Vitalik
+1  A: 

You could define the methods to modify ModelProject objects internal, so that other projects using ModelProject will not be able to call those methods, then use the InternalsVisibleToAttribute to grant PlugInProject access to the internal methods of ModelProject.

Paolo Tedesco
You'd need to make the projects friend assemblies for this: http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx
David Neale
Perfect this is exactly what I needed. Thanks.
Eric Anastas