Groups | Blog | Home
all groups > dotnet faqs > march 2004 >

dotnet faqs : Write customized attribute which has functionality like ObseleteAttribute


indianiowan NO[at]SPAM yahoo.com
3/16/2004 12:14:53 AM
Hello again Attribute Gurus...
Can someone throw an idea, on what to tweak, or flush out, some kind
of code. if one has to write a custom attribute like
ObseleteAttribute, with the aim to inject the code in various methods
at compile time, the example of code that needs to be injected is like
customized logging.
Have a nice day.
Thank you
Nicholas Paldino [.NET/C# MVP]
3/16/2004 9:16:43 AM
Thomas,

This isn't completely true. You can implement context-bound objects
which will allow for call interception when it is determined that a call is
coming from outside of that context. There is an article in MSDN magazine
that explains how to to this titled "Aspect-Oriented Programming Enables
Better Code Encapsulation and Reuse", and it can be found at (watch for line
wrap):

http://msdn.microsoft.com/msdnmag/issues/02/03/aop/default.aspx


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Nicholas Paldino [.NET/C# MVP]
3/16/2004 9:28:39 AM
Thomas pointed out that the original poster wanted to do this at compile
time. What I recommended can't be done at compile time, but it can be done
at runtime to provide AOP-like functionality to objects.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:uYwbIG2CEHA.1604@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

Thomas Tomiczek [MVP]
3/16/2004 9:33:24 AM
Unless you reimplement the compiler, it just can not be done.

Period.

Reality.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---

Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.


[quoted text, click to view]

Thomas Tomiczek [MVP]
3/16/2004 3:30:48 PM
It is absolutly true.

See the original question:

[quoted text, click to view]


Your approach does not work at compile time, so it is not a valid solution
per definition.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---

Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.


"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:uYwbIG2CEHA.1604@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button