title: How to proxy calls to the instance of an object
body: <p><strong>Edit:</strong> Changed question title from "Does C# allow method overloading, PHP style (__call)?" - figured out it doesn't have much to do with actual question. Also edited question text.</p>
  
  <p>What I want to accomplish is to proxy calls to a an instance of an object methods, so I could log calls to any of its methods.</p>
  
  <p>Right now, I have code similar to this:</p>
  
  <pre><code>class ProxyClass {
      static logger;
      public AnotherClass inner { get; private set; }
      public ProxyClass() { inner = new AnotherClass(); }
  }
  
  class AnotherClass {
      public void A() {}
      public void B() {}
      public void C() {}
      // ...
  }
  
  // meanwhile, in happyCodeLandia...
  ProxyClass pc = new ProxyClass();
  pc.inner.A(); // need to write log message like "method A called"
  pc.inner.B(); // need to write log message like "method B called"
  // ...
  </code></pre>
  
  <p>So, how can I proxy calls to an object instance in extensible way? Method overloading would be most obvious solution (if it was supported in PHP way). By extensible, meaning that I don't have to modify ProxyClass whenever AnotherClass changes.</p>
  
  <p>In my case, AnotherClass can have any number of methods, so it wouldn't be appropriate to overload or wrap all methods to add logging.</p>
  
  <p>I am aware that this might not be the best approach for this kind of problem, so if anyone has idea what approach to use, shoot.</p>
  
  <p>Thanks!</p>