473,499 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically finding what functions have a specific attribute

We have a WinForm application that we would like to add security to. We would
also like to set up a configuration utility that would make it easier to
assign or remove rights.

When using code access security is there a way to create a list of
functions/classes that have a security attribute assigned to them?

i.e a new module is added. In the assembly there are certain items that can
be added or removed from specific groups. What are they?

Is there a code sample out there to show this?

Thanks!
Jul 29 '06 #1
1 1022
you should write a custom attribute to apply to a specific
function.more information about it.plz refer to MSDN.

Here is a sample demo to show how to find a specific attribute.

using System;

[Developer("Joan Smith", "42", Reviewed = true)]
class MainApp
{
public static void Main()
{
//Call function to get and display the attribute.
GetAttribute(typeof(MainApp));
}

public static void GetAttribute(Type t)
{
//Get instance of the attribute.
DeveloperAttribute MyAttribute = (DeveloperAttribute)
Attribute.GetCustomAttribute(t, typeof (DeveloperAttribute));

if(null == MyAttribute)
{
Console.WriteLine("The attribute was not found.");
}
else
{
//Get the Name value.
Console.WriteLine("The Name Attribute is: {0}." ,
MyAttribute.Name);
//Get the Level value.
Console.WriteLine("The Level Attribute is: {0}." ,
MyAttribute.Level);
//Get the Reviewed value.
Console.WriteLine("The Reviewed Attribute is: {0}." ,
MyAttribute.Reviewed);
}
}
}

Sincerely,
simida

Stedak 写道:
We have a WinForm application that we would like to add security to. We would
also like to set up a configuration utility that would make it easier to
assign or remove rights.

When using code access security is there a way to create a list of
functions/classes that have a security attribute assigned to them?

i.e a new module is added. In the assembly there are certain items that can
be added or removed from specific groups. What are they?

Is there a code sample out there to show this?

Thanks!
Jul 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
12539
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
27
4680
by: Nicholas Couch | last post by:
I have a little form with a couple of dynamically generated list boxes. When the user makes a selection from the first box, the second box is refreshed. When they make a selection from the second...
6
3285
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
11
2264
by: Steven D'Aprano | last post by:
Suppose I create a class with some methods: py> class C: .... def spam(self, x): .... print "spam " * x .... def ham(self, x): .... print "ham * %s" % x .......
1
1552
by: Matthew Smith | last post by:
I have a situation where I have to dynamically add controls at runtime. I am not sure how to deal with postback and retaining values in textboxes. I have seen examples where you have to include...
4
1427
by: topdawg147 | last post by:
This question might be for another group, but since I use vb.net, I thought I'd ask here.... I'm looking to clean up some code. Is there a development tool to tell me which functions are not...
5
1305
by: Nathan Harmston | last post by:
Hi, Sorry if the subject line of post is wrong, but I think that is what this is called. I want to create objects with class Coconuts(object): def __init__(self, a, b, *args, **kwargs):...
20
4254
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. ...
275
12027
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.