<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Hardcore</title>
        <link>http://www.ayende.com/Blog/category/505.aspx</link>
        <description>Hardcore</description>
        <language>en-US</language>
        <copyright>Ayende Rahien</copyright>
        <managingEditor>Ayende@ayende.com</managingEditor>
        <generator>Subtext Version 1.9.3.51</generator>
        <item>
            <title>Internal Stripping</title>
            <link>http://ayende.com/Blog/archive/2008/03/12/Internal-Stripping.aspx</link>
            <description>&lt;p&gt;Okay, my dislike for internal is well known at this stage, I believe. What I want to talk about today is the process of stripping (ignoring) the internal keyword. As I have recently discussed, I have recently run into several situations where certain parts of the framework, marked as internal, would have been so very useful to me. &lt;/p&gt; &lt;p&gt;A while ago I stripped internal out of &lt;a href="http://rhino-tools.svn.sf.net/svnroot/rhino-tools/trunk/rhino-commons/Rhino.Commons/ToPublic/SqlCommandSet.cs"&gt;SqlCommandSet&lt;/a&gt;, and I have used the same technique since. It is a hack, mind you, but a very useful one.&lt;/p&gt; &lt;p&gt;Now, we can make use of internals in the framework if we use Reflection, but that has a perf cost to it. I found that by caching the results of the Reflection, and a bit of delegates, we can fairly easily expose the required functionality out, without paying a high price for performance. &lt;a href="http://rhino-tools.svn.sf.net/svnroot/rhino-tools/trunk/rhino-commons/Rhino.Commons/ToPublic/SqlCommandSet.cs"&gt;SqlCommandSet&lt;/a&gt; is a good example of this technique in action, and it has been &lt;em&gt;wildly&lt;/em&gt; successful.&lt;/p&gt; &lt;p&gt;Another, a more advance version, but one that I don't know the ROI for, is to use Lightweight Code Generation to add accessors to the internal methods already there. I am pretty sure it is not worth the trouble.&lt;/p&gt; &lt;p&gt;Of course, if it is internal, you have to make sure that there are tests around it, because otherwise it could change without warning and you'll not know. There are other issues with the method, mostly around support, robustness (the internal code may make assumptions about its use), etc.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10095.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/12/Internal-Stripping.aspx</guid>
            <pubDate>Wed, 12 Mar 2008 20:09:50 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/03/12/Internal-Stripping.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10095.aspx</wfw:commentRss>
        </item>
        <item>
            <title>AOP With Windsor: Adding Caching to IRepository&lt;T&gt; based on T's attributes</title>
            <link>http://ayende.com/Blog/archive/2007/03/11/AOP-With-Windsor-Adding-Caching-to-IRepositoryT-based-on-Ts.aspx</link>
            <description>&lt;br /&gt;
Okay, this is a fairly wacky scenario, I admit. &lt;br /&gt;
I am using IRepository&amp;lt;T&amp;gt; for my data access, and I wanted to be able to specify attributes on the T (that is, on the entity, not the repository) and have the behavior of the class change. For instance, if I have IRepository&amp;lt;OrderStatus&amp;gt;, that is something that changes very rarely, so I can safely cache that. But I want to put [Cacheable] on OrderStatus, not on OrderStatusRepository.  To make matter worse, I never explicitly register IRepository&amp;lt;OrderStatus&amp;gt;, I only register IRepository&amp;lt;T&amp;gt; and let Windsor figure the rest of it out.&lt;br /&gt;
I thought that it would be a major hurdle, but it turn out to be fairly easy.&lt;br /&gt;
&lt;br /&gt;
Windsor has the concept of Component Model, basically everything that Windsor knows about a component, and you can plug your own contributers, which can add additional knowledge to Windsor.&lt;br /&gt;
&lt;br /&gt;
&lt;p style="margin-bottom: 0.0001pt; text-align: left; line-height: normal; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; Inspect the model and add a caching interceptor if appropriate &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CachingInterceptorContributer&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IContributeComponentModelConstruction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; Inspect the model and add a caching interceptor if appropriate &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ProcessModel(&lt;span style="color: rgb(43, 145, 175);"&gt;IKernel&lt;/span&gt; kernel, &lt;span style="color: rgb(43, 145, 175);"&gt;ComponentModel&lt;/span&gt; model)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; isRepository = model.Service.IsGenericType &amp;amp;&amp;amp; &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;            &lt;/span&gt;model.Service.GetGenericTypeDefinition() == &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository&lt;/span&gt;&amp;lt;&amp;gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (isRepository == &lt;span style="color: blue;"&gt;false&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Type&lt;/span&gt; entityType = model.Service.GetGenericArguments()[0];&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; cacheable = entityType&lt;br /&gt;
              .GetCustomAttributes(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;CacheableAttribute&lt;/span&gt;),&lt;span style="color: blue;"&gt;true&lt;/span&gt;).Length != 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align: left; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(cacheable==&lt;span style="color: blue;"&gt;false&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;model.Interceptors.Add(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;InterceptorReference&lt;/span&gt;(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;CachingInterceptor&lt;/span&gt;)));&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;span lang="HE" style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" dir="rtl"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
This checks that the component is an IRepository&amp;lt;T&amp;gt;, and that the T has [Cacheable] attribute. The real nice thing here is that it will be called when Windsor decides that it needs to create an IRepository&amp;lt;OrderStatus&amp;gt;, thereby giving me the chance to add the interceptor to this (and only this) repository.&lt;br /&gt;
The interceptor is very simple, and builds on  already existing code:&lt;br /&gt;
&lt;br /&gt;
&lt;p style="margin-bottom: 0.0001pt; text-align: left; line-height: normal; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; Add query caching capabilities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CachingInterceptor&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IInterceptor&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;IOnBehalfAware&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; typeName;&lt;o:p&gt;&lt;br /&gt;
 &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0001pt; text-align: left; line-height: normal; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; Intercepts the specified invocation and adds query caching capabilities&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;param name="invocation"&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;The invocation.&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Intercept(&lt;span style="color: rgb(43, 145, 175);"&gt;IInvocation&lt;/span&gt; invocation)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;With&lt;/span&gt;.QueryCache(typeName))&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;            &lt;/span&gt;invocation.Proceed();&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;br /&gt;
 &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0001pt; text-align: left; line-height: normal; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; Sets the intercepted component model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;param name="target"&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;The target.&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; SetInterceptedComponentModel(&lt;span style="color: rgb(43, 145, 175);"&gt;ComponentModel&lt;/span&gt; target)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;typeName = target.Service.GetGenericArguments()[0].FullName;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align: left; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;span lang="HE" style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" dir="rtl"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;br /&gt;
I am using this just to tell NHibernate that it should cache the query, since NHibernate would already be caching the entities in its second level cache (I might show later how I handled that). Now to register the contributer:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;p style="margin-bottom: 0.0001pt; text-align: left; line-height: normal; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; Registers various add-ons to the container&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;///&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;AdditionalFunctionalityFacility&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;AbstractFacility&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align: left; direction: ltr; unicode-bidi: embed;" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; The actual addition of resolvers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Init()&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;      &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;Kernel.AddComponent(&lt;span style="color: rgb(163, 21, 21);"&gt;"caching.interceptor"&lt;/span&gt;, &lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;CachingInterceptor&lt;/span&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;        &lt;/span&gt;Kernel.ComponentModelBuilder.AddContributor(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CachingInterceptorContributer&lt;/span&gt;());&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;
&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;span lang="HE" style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" dir="rtl"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
And that is it. I register a facility, which takes care of configuring the interceptor and the contributer, and I am set. I can now simply put [Cacheable] on an entity, and it will cache that in all levels.&lt;br /&gt;
This technique is a powerful one, and I do believe that I will use it more in the future.&lt;img src="http://ayende.com/Blog/aggbug/9101.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2007/03/11/AOP-With-Windsor-Adding-Caching-to-IRepositoryT-based-on-Ts.aspx</guid>
            <pubDate>Sun, 11 Mar 2007 18:21:15 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2007/03/11/AOP-With-Windsor-Adding-Caching-to-IRepositoryT-based-on-Ts.aspx#feedback</comments>
            <slash:comments>9</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/9101.aspx</wfw:commentRss>
        </item>
        <item>
            <title>IL Wierdness</title>
            <link>http://ayende.com/Blog/archive/2006/10/06/7219.aspx</link>
            <description>&lt;p&gt;    I am in deep dive mode into Dynamic Proxy 2, and I am once again confronted with IL Madness. I can understand IL well enough to say that this piece of could is a very long way to say: "Console.WriteLine('a');". The problem is that it doesn't do that.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #999999 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #999999 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; WIDTH: 100%; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; BACKGROUND-COLOR: #ffffe1"&gt;    IL_0000:  nop&lt;br /&gt;        IL_0001:  ldc.i4.s   97&lt;br /&gt;        IL_0003:  box        [mscorlib]System.Char&lt;br /&gt;        IL_0008:  stloc.0&lt;br /&gt;        IL_0009:  ldloc.0&lt;br /&gt;        IL_000a:  unbox   [mscorlib]System.Char&lt;br /&gt;        IL_000f:  stloc.1&lt;br /&gt;        IL_0010:  ldloc.1&lt;br /&gt;        IL_0011:  call       void [mscorlib]System.Console::WriteLine(char)&lt;br /&gt;        IL_0016:  nop&lt;br /&gt;        IL_0017:  ret&lt;/div&gt;&lt;p&gt;    Instead, it just prints a random character. The issue is with IL_000a, where the unbox reside. The C# Compiler output an unbox.any in this scenario, and then it works. Pursuing the documenation for those instructions doesn't reveal much. unbox.any is basically an unbox followed with ldobj in this scenario, and unbox short circuit itself to just copy the address of the boxed value.&lt;/p&gt;&lt;p&gt;    What this looks to me is that I'm actually storing the &lt;em&gt;reference&lt;/em&gt; to the char variable, but I have no idea why. Any explanation is welcome.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/7219.aspx" width="1" height="1" /&gt;</description>
            <guid>http://ayende.com/Blog/archive/2006/10/06/7219.aspx</guid>
            <pubDate>Fri, 06 Oct 2006 20:33:46 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2006/10/06/7219.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/7219.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>