title: Automatically creating a wrapper to implement an interface
body: <p>I have some classes that <em>don't</em> implement a certain interface but structurally comply to that interface.</p>
  
  <pre><code>interface IFoo {
      void method();
  }
  
  class Bar {  // does not implement IFoo
     public void method() {...}
  }
  </code></pre>
  
  <p>Now, I could write a wrapper around those classes that simply delegate to the wrapped class</p>
  
  <pre><code>class BarWrapper : IFoo {
     Bar bar = new Bar();
     public void method()
     {
        bar.method();
     }
  }
  </code></pre>
  
  <p>But that's lots of tedious work. Can those wrapper classes somehow be generated automatically? Something like:</p>
  
  <p><code>IFoo foo = CreateWrapper&lt;IFoo&gt;(new Bar());</code></p>
  
  <p>I'm sure you could do this with Reflection.Emit but I've never used that and it doesn't look very easy at first glance.</p>
  
  <p>Is there an easier way or is there perhaps a library that already implements this?</p>