Howard,

You might want to check out some of the interception examples that are out
on the web... There's actually quite a lot of them... Furthermore, Don Box
does a great job describing the CLR's facilities for method-call
interception in his book on the Runtime [1]. Then there are also two
MSDN-Magazine articles on this topic [2, 3].

HTH,

Stefan

[1] Don Box. Essential .NET, Volume I: The Common Language Runtime. Addison
Wesley. 2000.
[2] Dharma Shukla, Simon Fell, and Chris Sells. 'Aspect-Oriented Programming
Enables Better Code Encapsulation and Reuse', in: MSDN Magazine. 17 (3).
Microsoft. March 2002.
http://msdn.microsoft.com/msdnmag/issues/02/03/AOP/default.aspx
[3] Juval Lowy. 'Decouple Components by Injecting Custom Services into Your
Object's Interception Chain', in: MSDN Magazine. 18 (3). Microsoft. March
2003.
http://msdn.microsoft.com/msdnmag/issues/03/03/ContextsinNET/default.aspx

(beware of line breaks!)


From: "Howard Dierking" <[EMAIL PROTECTED]>
To: "Moderated discussion of advanced .NET topics."
<[EMAIL PROTECTED]>
Subject: Need to Append a line to an existing method
Date: Thu, 29 May 2003 17:12:00 -0400

I'm working on creating a transparent auditing system whereby methods can
be flagged for auditing using attributes and the system, implemented in the
object or the object base class can process audit information.

The approach that I've taken thusfar is to create a custom attribute
(basically data only), and create a base class that goes through the type
information to determine which methods are flagged for auditing.

My thought at this point is to, when a method is found that requires
auditing,  append a line of code to that method (calling a _WriteAudit_
method) and immediately recompile.  In the Reflection.Emit namespace, I can
see how I could build methods from scratch -- however, I don't see how to
edit a method.

Also, concerned about the performance implications of this approach --
especially if there is a more standard approach for accomplishing my
aforementioned goal.  thoughts?

_howard

_________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

Reply via email to