473,386 Members | 1,786 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,386 software developers and data experts.

Custom Attributes (AttributeTargets.Property) and Property Type

Hi

I've create a custom attribute class "MyAttribute" with
[AttributeUsage(AttributeTargets.Property)]

Is there a way to get the type of the property myAttribute is applied to?

I need to raise an exception if "MyAttribute" is attached to a non-string
type of property, for example. In other words I have to make sure
MyAttribute does not only targets properties but also string properties.

~Zarko Gajic

Nov 17 '05 #1
1 1949
Is there a way to get the type of the property myAttribute is applied to?


Not unless you manually pass it to the attribute instance at runtime
(via a PropertyInfo for example).


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2

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

Similar topics

3
by: Nick | last post by:
My client uses a SQL Database to store their usernames and passwords, and I do not believe they have AD...no big deal... I wrote a class to create a generic identity and generic principal so that...
2
by: Zach Mortensen | last post by:
I can't seem to get dynamically-compiled JScript code to use C#-defined custom attributes. I have a simple attribute and a class defined in a C# assembly: namespace MyNamespace { public...
3
by: zsilence_is | last post by:
I have created my attribute with the constructor as follows: Public Sub New(ByVal value As Object) MyBase.New(value) End Sub now when I try to use it like this <Att(1)> it get the...
2
by: Harry F. Harrison | last post by:
I get 2 compile errors on assembly attributes after creating a custom attribute. If I comment out the attribute, the errors go away. I don't get it because my attribute specifies class usage,...
3
by: Dan | last post by:
Hi, I am messing around with custom attributes and may have understood the concept a bit wrong:- I have a simple class that has a few public properties that individually have custom...
3
by: Marc Robitaille | last post by:
Hello, I have this Field attribut class and a Client class that uses this Attribut Class <AttributeUsage(AttributeTargets.Property)_ Public Class Field Inherits Attribute Private _FieldName...
1
by: =?Utf-8?B?d2luZHNpbQ==?= | last post by:
Hi, I have a custom attribute targing Property: public class StatefulPropertyAttribute : Attribute{} and all the properties marked with will be handled by public...
4
by: hardieca | last post by:
Hi! I have built a custom attribute that tracks my list of things left to do in my application: Public Class SomeClass ... Using reflection, I am able to find all attributes within the...
1
by: hardieca | last post by:
Hi! I decorate my unfinished classes and methods with a custom TODO attribute (as in things To Do). Using reflection, I am then able to parse through my classes and output all TODOs to a list I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.