title: Dynamic creation of object instances
body: <p>We have a system that creates dynamically defined objects as a core aspect of the processing. I would like to be able to create an class object and make these objects instances of this class, implementing all of the functionality that this particular object has.</p>
  
  <p>The problem is, these objects really need to dynamically inherit from a base class, and override null methods etc. In essence, I need something of a dynamic class structure (and I have proposed compiling the definitions into a proper class model, but that is some distance away). The best approach i can come up with is to create a class instance with a set of blank properties, and dyamically replace these properties with methods if these features are implemented.</p>
  
  <p>I have also looked at Castles DynamicProxy approach, which might be a useful route (intercepting the calls and actioning them if appropriate), but this seems more complex than it should be.</p>
  
  <p>So any suggestions? What would the best, most .Net-like approach to this be? As I look at the problem, it seems like there should be a really good and easy solution.</p>
  
  <hr>
  
  <p>Just to help, a simple example (semi-pseudocode - I know it is not fully working):</p>
  
  <pre><code>class thing
  {
      public void Process()
      {
          foo();
          bar();
      }
      private foo(){}
      private bar(){}
  }
  
  a=new thing() {foo=DoFoo}
  b=new thing() {bar=DoBar}
  </code></pre>
  
  <p>I want to be able to call a.Process and b.Process, and have them both run. Bear in mind that these objects have some 20-30 properties/methods that might need setting (setting them is easy, but some of them might be substantial methods)</p>