Fixing an issue with output parameters that are of type IntPtr
[castle.git] / AspectSharp / docs / faq1.html
blob97bccaac037243fe90961ac7c05e7214a4a28949
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
4 <head>
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">
12 <!--
13 body
15 font-family: verdana;
16 font-size:x-small;
20 color: navy;
22 a:hover
24 color: blue;
28 color:green;
30 table
32 font-size:x-small;
34 .code
36 font-family:"Lucida Console", "Courier New", Courier;
37 font-size:small;
38 background-color: #DDDDDD;
39 width: 100%;
40 border: 2px dashed #000000;
41 margin: 2pt;
42 padding: 2pt;
44 -->
45 </style>
46 </head>
49 <body>
50 <table border="1" cellspacing="0" bordercolor="black" width="100%">
51 <tr>
52 <td>Aspect# - An AOP framework for the .NET</td>
53 </tr>
54 </table>
56 <h1><img src="http://aspectsharp.sourceforge.net/logo.gif" alt="Aspect# Logo. By Ricardo Aloise." /></h1>
58 <p></p>
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.
65 </p>
67 <p>
68 Supposing that every IContentProvider implementation is created by a ContentProviderFactory,
69 you can wrap the factory on the bootstrap of your application:
70 </p>
72 <p class="code">
73 public interface IContentProviderFactory <br/>
74 {<br/>
75 &nbsp;&nbsp;IContentProvider Create( String key );<br/>
76 }<br/>
77 <br/>
78 public class DefaultContentProviderFactory : IContentProviderFactory<br/>
79 {<br/>
80 &nbsp;&nbsp;public IContentProvider Create( String key )<br/>
81 &nbsp;&nbsp;{<br/>
82 &nbsp;&nbsp;&nbsp;&nbsp;/// ...<br/>
83 &nbsp;&nbsp;}<br/>
85 </p>
87 <p>Now we intercept all invocation to the Create method and wrap
88 the returned content providers.</p>
90 <p class="code">
91 import YourCompany.CMS.ContentProviders in YourCompanyAssembly<br/>
92 import YourCompany.CMS.Aop.Interceptors<br/>
93 <br/>
94 aspect WrapContentProviderFactory for DefaultContentProviderFactory<br/>
95 <br/>
96 &nbsp;&nbsp;pointcut method(* Create(*))<br/>
97 &nbsp;&nbsp;&nbsp;&nbsp;advice(ContentProviderFactoryInterceptor)<br/>
98 &nbsp;&nbsp;end<br/><br/>
99 end</p>
101 <p>And here is the interceptor implementation</p>
103 <p class="code"> public class ContentProviderFactoryInterceptor : IMethodInterceptor<br/>
104 {<br/>
105 &nbsp;&nbsp;public object Invoke(IMethodInvocation invocation)<br/>
106 &nbsp;&nbsp;{<br/>
107 &nbsp;&nbsp;&nbsp;&nbsp;object contentProvider = invocation.Proceed();<br/>
108 &nbsp;&nbsp;&nbsp;&nbsp;return engine.Wrap( contentProvider );<br/>
109 &nbsp;&nbsp;}<br/>
110 } </p>
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
113 instance itself.</p>
116 <hr noshade>
117 <p>20-09-04 - The Aspect# Team
118 </p>
121 </body>
122 </html>