title: Selectively intercepting methods using autofac and dynamicproxy2
body: <p>I'm currently doing a bit of experimenting using Autofac-1.4.5.676, autofac contrib and castle DynamicProxy2.  The goal is to create a coarse-grained profiler that can intercept calls to <strong>specific</strong> methods of a particular interface.  </p>
  
  <p>The problem: I have everything working perfectly apart from the selective part.  I could be wrong, but I think I need to marry up my interceptor with an IProxyGenerationHook implementation, but I can't figure out how to do this.</p>
  
  <p>My code looks something like this:</p>
  
  <p>The interface that is to be intercepted &amp; profiled (note that I only care about profiling the <strong>Update()</strong> method)</p>
  
  <pre><code>public interface ISomeSystemToMonitor
  {
      void Update(); // this is the one I want to profile
      void SomeOtherMethodWeDontCareAboutProfiling();
  }
  </code></pre>
  
  <p>Now, when I register my systems with the container, I do the following:</p>
  
  <pre><code>// Register interceptor gubbins
  builder.RegisterModule(new FlexibleInterceptionModule());
  builder.Register&lt;PerformanceInterceptor&gt;();
  
  // Register systems (just one in this example)
  builder.Register&lt;AudioSystem&gt;()
  .As&lt;ISomeSystemToMonitor&gt;)
  .InterceptedBy(typeof(PerformanceInterceptor)); 
  </code></pre>
  
  <p>All ISomeSystemToMonitor instances pulled out of the container are intercepted and profiled as desired, other than the fact that it will intercept all of its methods, not just the Update method.</p>
  
  <p>Now, how can I extend this to exclude all methods other than Update()?  As I said, I don't understand how I'm meant to inform the container that, "for the ProfileInterceptor, use this implementation of IProxyHookGenerator".  </p>
  
  <p>All help appreciated, cheers!  Also, please note that I can't upgrade to autofac2.x right now; I'm stuck with 1.</p>