473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Some attribute questions

8
Hello.

Can i specify that an attribute can only be applied to a property with a set accessor?

Can i get all attributes of a specific type of a class and then through the attribute instance get the members that they where applied to?

Thanks in advance.
Sep 30 '08 #1
2 1095
vanc
211 Expert 100+
I'm not fully understand what you're asking about. If you can revise your question, I may help you out here. If you can also throw in some pseudo codes, that's great to illustrate your idea. Cheers.
Oct 1 '08 #2
xend
8
what i want to know is if there is a way to specify to the compiler that a custom attribute can only be applied to a property with a set accessor (CanWrite == true).

Something like AttributeUsage does.

[AttributeUsage(AttributeTargets.Property)]
public class SomeAttribute : Attribute {}

public SomeClass
{
[SomeAttribute ] //I want a compiler error here because the attribute SomeAttribute is applied to an property that does not have a set
public int onlyGetProp { get {return 0;} }

[SomeAttribute ] //
public int onlyGetProp { get {return 0;} set { /*do something*/} }
}

Is it possible to have the described behavior?

Also can i do something like this:

Attribute[] atts = (Attribute[])GetType().GetCustomAttributes(typeof(SomeAttribut e), true);
foreach(Attribute a in atts)
{
MemberInfo mi = a.getMember(); //this method should give the member info where the instance of the attribute has applied, does such thing exists???
}
Oct 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Player | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello I am teaching myself python, and I have gotten a long way, it's quite a decent language and the syntax is great :) However I am having a...
0
by: Ray Tayek | last post by:
hi, trying to convert some csv files into xsml and pulling a few hairs out :(. using the files below. a java program will parse the csv and take care of strange names and notes that line breaks in...
6
by: futurepy | last post by:
Hello, I am not good at JS at all. If you are reading this message with the IE, please move the cursor up to the top of the page. When the cursor stops at an icon, a rectangle slot will...
1
by: Tony Johansson | last post by:
Hello I'm trying to learn XML by reading a book. There is some text in the book that I don't understand so I try to ask you out there. My first question is does this statement mean that ...
3
by: Patrick | last post by:
>Is it actually valid to have an XML document with 2 XML Elements having the same ID attribute? XML Spy seems to allow something like the following <?xml version="1.0" encoding="UTF-8"?>...
3
by: Ken Varn | last post by:
I am just starting the process of creating ASP.NET server controls. I have created controls for .NET applications, but have just started with ASP.NET. I am a little confused about some areas that...
14
by: gooooglegroups | last post by:
I want to transform the following xml file ------------------------------------------------------------------------ <?xml version="1.0" encoding="ISO-8859-1"?> <a> <b attrib="if 3 2"> </b> ...
12
by: Goran Djuranovic | last post by:
Hi all, I ran into a problem where my XMLTextReader fails on .Read() when I have "<" character in one of the attribute's values. What I am trying to do is replace illegal characters ("<", "&" ,...
0
by: Tom Chi | last post by:
Hi, I am porting an ASP.NET Javascript/C# application from .NET framework 1.x (everything works there) to 2.0 on Windows Server 2003 SP1, and experieced problem (null reference) while trying to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.