سؤال

I have a C# class library that is going to be used in 2 different projects. One of them should access to all public classes and methods and the other one should only access to some of the classes and methods .

what is the best solution ?

هل كانت مفيدة؟

المحلول

I think your best bet would be InternalsVisibleTo attribute

Ordinarily, types and members with internal scope (in C#) and friend scope (in Visual Basic) are visible only in the assembly in which they are defined. The InternalsVisibleToAttribute attribute makes them also visible to the types in a specified assembly, which is known as a friend assembly. The attribute is applied at the assembly level. This means that it can be included at the beginning of a source code file, or it can be included in the AssemblyInfo file in a Visual Studio project

Of course this doesn't prevent people from calling your methods using reflection

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top