PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Custom Attributes (AttributeTargets.Property) and Property Type

 
 
Zarko Gajic
Guest
Posts: n/a
 
      8th Apr 2005
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



 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      8th Apr 2005

>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.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not find a property named '... ' on the type specified by the DataObjectTypeName property in ObjectDataSource '...' Anabela Silva Microsoft ADO .NET 3 7th Feb 2010 01:09 PM
Custom attributes on property Watty Microsoft VB .NET 5 5th Jun 2009 11:25 AM
Could not find a property named '... ' on the type specified by the DataObjectTypeName property in ObjectDataSource '...' Anabela Silva Microsoft ASP .NET 0 1st Nov 2006 07:08 PM
Retrieving Custom Attributes from a property using StackTrace =?Utf-8?B?TWFyayBSLiBEYXdzb24=?= Microsoft C# .NET 3 10th Feb 2006 10:37 PM
Property of custom type =?Utf-8?B?SGFyc2hhZA==?= Microsoft Dot NET 0 16th Dec 2004 01:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 AM.