title: Implement a dictionary of classes for a pseudo class factory
body: <p>I´m trying to buld a class factory like that: </p>
  
  <pre><code>public class Toyota() {};
  public class Bmw() {};
  public class Mercedes() {};
  
  public class BrandFactory
  {
      private Dictionary&lt;string, object&gt; _Brands = new Dictionary&lt;string, object&gt; {
          {"Toyota", Toyota},
          {"Bmw", Bmw}, 
          {"Mercedes", Mercedes}
      }
  
     public object GetBrand(string brandName)
     {
         return = BusinessManagers[brandName].Invoke;
     }
  }
  </code></pre>
  
  <p>This is the idea, but it´s not working - I can´t even compile the above code as the Dictionary cannot associate an <code>'object'</code> with the function. I tried <code>Func&lt;&gt;</code> as well, but in that case it requires a previous type.</p>
  
  <p>So, here are my questions:
  Is that a correct way to implement this 'pseudo factory' ? The code came from the example at <a href="http://www.codeproject.com/Articles/383845/Factory-Method-Pattern-With-Expression-Trees-using" rel="nofollow">example code</a></p>
  
  <p>If so, what needs to be fixed in the above code ?</p>
  
  <p>The reason I´m asking that is because I need to create a new object based on a string that is received from a cliente application using Ajax. Like:</p>
  
  <p><code>AjaxCall -&gt; String Containing Object Name -&gt; Object Inoke -&gt; Method Call -&gt; Send result back to client</code></p>
  
  <p>The Method Call is a standard for all implementation of <code>Brand</code>.</p>
  
  <p>Please can someone help me with that ?</p>
  
  <p>Thanks.</p>