in Education by (1.9m points)
I want to make custom attributes on classes to restrict who calls them.

For example:


public class MyData {


How to do that? So I want to really make some sort of Permission-class.

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.9m points)
You either use the ones that already exist, or you write your own and hook them into the Code Access Security architecture. This has been around for a really long time, and I was able to find these articles:

Code Access Security

Creating Your Own Code Access Permissions

Cut-away from the link above:

Implementing a custom code access permission involves the following steps, some of which are optional. Each step is described in a separate topic.

Design the Permission class.

Implement the IPermission and IUnrestrictedPermission interfaces.

Implement the ISerializable interface, if necessary for performance or to support special data types.

Handle XML encoding and decoding.

Add support for declarative security, by implementing an Attribute class.

Demand custom permission for your permission, where appropriate.

It's really steps 1, 2, 5 and 6 that are of interest to you.

Related questions

0 votes
asked Dec 29, 2021 in Education by JackTerrance (1.9m points)
0 votes
asked May 6 in Education by JackTerrance (1.9m points)