473,729 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom attributes

I understand the syntax of custom attributes, but I have no idea what they
are supposed to do. Anyone care to give me a clue as to their functionality
?
Nov 16 '05 #1
3 2145
"Edward Diener" <ed******@tropi csoft.com> wrote:
I understand the syntax of custom attributes, but I have no idea what they
are supposed to do. Anyone care to give me a clue as to their functionality ?


An attribute can add functionality or constraints to the attributed
"target". ManagedXLL for example provides a custom [WorksheetFuncti on]
attribute, that enables the the attributed method to be called from Excel
worksheets without modifying the method itself.

Browse the .NET class library and you will find lots of attributes and
examples.

Attributes also replace spearate IDL files in VC7.
Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #2
Jens Thiel wrote:
"Edward Diener" <ed******@tropi csoft.com> wrote:
I understand the syntax of custom attributes, but I have no idea
what they are supposed to do. Anyone care to give me a clue as to
their functionality ?


An attribute can add functionality or constraints to the attributed
"target". ManagedXLL for example provides a custom [WorksheetFuncti on]
attribute, that enables the the attributed method to be called from
Excel worksheets without modifying the method itself.


How does a custom attribute change usage of a particular type in MC++ ? Does
it direct the compiler to act differently ? That would seem to be impossible
since the compiler can not know about custom attributes. Does it allow the
programmer at run-time to react to a particular custom attribute by querying
the type for its attributes ? That would seem more probable but I am looking
for a practical example in MC++ code where this occurs.

In other words, let's say I create a custom attribute and use it for a
certain MC++ type. How practically would another programmer use my custom
attribute for added functionality when accessing an object of that type at
run-time ?
Nov 16 '05 #3
"Edward Diener" <ed******@tropi csoft.com> wrote
Jens Thiel wrote:
"Edward Diener" <ed******@tropi csoft.com> wrote:
I understand the syntax of custom attributes, but I have no idea
what they are supposed to do. Anyone care to give me a clue as to
their functionality ?
An attribute can add functionality or constraints to the attributed
"target". ManagedXLL for example provides a custom [WorksheetFuncti on]
attribute, that enables the the attributed method to be called from
Excel worksheets without modifying the method itself.


How does a custom attribute change usage of a particular type in MC++ ?

Does it direct the compiler to act differently ?
No. Attributes are usually inspected by some kind of "container" that know
about your custom attribute.
Does it allow the
programmer at run-time to react to a particular custom attribute by querying the type for its attributes ? That would seem more probable but I am looking for a practical example in MC++ code where this occurs.
Yes, a custom attribute is usually read through reflecting on the target.
See ICustomAttribut eProvider.
In other words, let's say I create a custom attribute and use it for a
certain MC++ type. How practically would another programmer use my custom
attribute for added functionality when accessing an object of that type at
run-time ?


I suggest that you lookup "Extending Metadata Using Attributes" on MSDN or
have a look at the classes derived from System.Attribut e. There are lots of
examples.
Jens.
--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #4

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

Similar topics

5
454
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: public class SomeClass : IEmptyInterface or
1
2141
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001a5). Display.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000108). The help for LNK2022 is completely useless:
1
4209
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI standard). So I downloaded the VC++ 2005 Tools Refresh (http://tinyurl.com/5mdq2). After that I tried to do a full rebuild, but my project wouldn't link anymore. I get the following errors: MSVCMRTD.lib(mstartup.obj) : error LNK2022: metadata...
3
3538
by: The Developer | last post by:
Hi All, I have a web application where I am adding a custom attribute to my ASP.NET text box control and changing value of that attribute at client side using JavaScript. My problem is that changed value of that custom attribute is not reflecting back at server side. Any ideas about this problem? Server side code: private void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false)
0
1043
by: Sanjay Pais | last post by:
This is an extension of an earlier post I have created a custom text box and compiled it and dropped it into my toolbox. However when I change the value of my custom property in design mode and switch between design mode to page source and back to design mode i am unable to retrieve the property value I set. Also the property setting in the html page is lost. Thsi is the error I get **********************************...
9
3137
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards level compliance. Ideally, I would like to be at XHTML 1.0 Strict. However, in my reading I have...
3
3195
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what the set piece of the Name property gets compiled to, which I am getting from the stack trace, then the attributes are not returned. For example, Class Person has a property called "Name" which has a custom attribute decorating it. Inside the set...
2
2527
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article is the usage of "Custom Attribute" in real life project. Can somebody please help me understand where are these informations really helpful in Development Environment; may be a few example(s) will help me understand.
1
1528
camel
by: camel | last post by:
Apologies if foolish question, but I somewhat expected Custom Attributes (i.e. inheriting from System.Attribute) decorating class properties to come through via WSDL to the proxy the same as built in Attributes (e.g., Xml .Serialization attributes). Have typically always accessed custom attributes in referenced assemblies rather than via WS so perhaps I imagined it...No attributes come through in generated proxy for WS so obviously...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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 we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.