PC Review


Reply
Thread Tools Rate Thread

Defining a Custom Attribute

 
 
=?Utf-8?B?S2VpdGggSGFycmlz?=
Guest
Posts: n/a
 
      26th Apr 2005
Is it possible to create an attribute targeted at a field that will
automatically create get/set properties for that field given a property name?


I envision the code would look like this:

[CreatPropertyAttribute("TextName","public","get/set")]
private string _name;
=========================================
Then this code would be created at runtime:

public string TextName
{
get { return _name; }
set { _name=value; }
}
===========================================

I am trying to better understand custom attributes and how they might
simplify my life. Is my proposed attribute possible or am I missing the
concept completely?

Thanks for any help.
-Keith
 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      26th Apr 2005
Keith,

>Is it possible to create an attribute targeted at a field that will
>automatically create get/set properties for that field given a property name?


No, that would require extending the compiler (or some kind of
pre-processing of the source file).



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
defining custom page size in XP bassfisherdt Windows XP Print / Fax 1 13th Jul 2004 07:03 PM
compile error after defining custom attribute Harry F. Harrison Microsoft VB .NET 2 21st Jun 2004 09:19 PM
Defining Custom Colors =?Utf-8?B?RGFuaWVsIFA=?= Microsoft Excel Programming 3 10th Feb 2004 10:01 PM
Custom attribute applying another attribute Andrew Roberts Microsoft Dot NET Framework 1 4th Sep 2003 06:52 PM
Defining custom paper size Esteban Vargas Windows XP Customization 0 25th Jul 2003 07:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:02 PM.