1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
5 <meta content=
"text/html;charset=ISO-8859-1" http-equiv=
"content-type">
6 <meta content=
"en" http-equiv=
"content-language">
7 <meta name=
"robots" content=
"index, follow/">
8 <meta name=
"keywords" content=
"AOP, Aspect, Aspect Oriented Programming, .NET, DotNet, C#, Aspect .Net, Aspect Sharp, AspectSharp, Aspect #, Aspect#, AOP .Net, Aspect Oriented Programming .NET " />
9 <meta name=
"description" content=
"A .NET AOP Framework, it uses Dynamic Proxies and XML configuration files as basis." />
10 <title>Aspect# - Two minutes tutorial
</title>
11 <style type=
"text/css">
36 font-family:"Lucida Console", "Courier New", Courier
;
38 background-color: #DDDDDD;
40 border: 2px dashed
#000000;
50 <table border=
"1" cellspacing=
"0" bordercolor=
"black" width=
"100%">
52 <td>Aspect# - An AOP framework for the .NET
</td>
56 <h1><img src=
"http://aspectsharp.sourceforge.net/logo.gif" alt=
"Aspect# Logo. By Ricardo Aloise." /></h1>
60 <h4>How to introduce AOP in a more transparent way?
</h4>
62 <p>Well, there is no way to wrap instances without using an engine instance.
63 Containers like Avalon Castle and SpringFramework can hide from the outside world
64 the wrapping. But you can use some tricky to minimize the engine invocation.
68 Supposing that every IContentProvider implementation is created by a ContentProviderFactory,
69 you can wrap the factory on the bootstrap of your application:
73 public interface IContentProviderFactory
<br/>
75 IContentProvider Create( String key );
<br/>
78 public class DefaultContentProviderFactory : IContentProviderFactory
<br/>
80 public IContentProvider Create( String key )
<br/>
82 /// ...
<br/>
87 <p>Now we intercept all invocation to the Create method and wrap
88 the returned content providers.
</p>
91 import YourCompany.CMS.ContentProviders in YourCompanyAssembly
<br/>
92 import YourCompany.CMS.Aop.Interceptors
<br/>
94 aspect WrapContentProviderFactory for DefaultContentProviderFactory
<br/>
96 pointcut method(* Create(*))
<br/>
97 advice(ContentProviderFactoryInterceptor)
<br/>
98 end
<br/><br/>
101 <p>And here is the interceptor implementation
</p>
103 <p class=
"code"> public class ContentProviderFactoryInterceptor : IMethodInterceptor
<br/>
105 public object Invoke(IMethodInvocation invocation)
<br/>
107 object contentProvider = invocation.Proceed();
<br/>
108 return engine.Wrap( contentProvider );
<br/>
111 <p>But if there's no aspect registered for the class? Don't worry, if the engine
112 couldn't find an Aspect definition for the specified type it will return the
117 <p>20-
09-
04 - The Aspect# Team