title: Create an alternative to serializable anonymous delegates
body: <p>there have been quite some posts about this, all trying to serialize a Func delegate.</p>
  
  <p>But could someone think of an alternative, when the use of the delegate is always clear?</p>
  
  <p>We have a generic create command, which takes a delegate as paramater in the constructor. This delegate will create the Item for the create command:</p>
  
  <pre><code>public class CreateCommand&lt;T&gt; : Command
  {
      public T Item;
      protected Func&lt;T&gt; Constructor;
  
      public ClientCreateCommand(Func&lt;T&gt; constructor)
      {
          Constructor = constructor;
      }
  
      public override void Execute()
      {
          Item = Constructor();
      }
  }
  </code></pre>
  
  <p>The command is used like this:</p>
  
  <pre><code>var c = new CreateCommand&lt;MyType&gt;( () =&gt; Factory.CreateMyType(param1, param2, ...) );
  History.Insert(c);
  </code></pre>
  
  <p>Then the History serializes the command and sends it to the server. ofc the delegate can't be serialized as is and we get an exception.</p>
  
  <p>Now could someone think of a very simple Constructor class that can be serialized and does the same job than the lambda expresseion? Means it takes a list of paramters and returns an instance of type T, that we then can write somethink like this:</p>
  
  <pre><code>var constructor = new Constructor&lt;MyType&gt;(param1, param2, ...);
  var c = new CreateCommand&lt;MyType&gt;(constructor);
  History.Insert(c);
  </code></pre>
  
  <p>How would the Constructor class look like? Thanks for any ideas!</p>