How do I dynamically pass in a Type for <T>
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1292480/pass-type-dynamically-to-t">Pass Type dynamically to &lt;T&gt;</a>  </p>
</blockquote>



<p>How would I do something like the below?
<strong>historyType</strong> is not a recognized type in Adapt.</p>

<pre><code>Type historyType = Type.GetType("Domain.MainBoundedContext.CALMModule.Aggregates.LocationAgg." + modifiedEntry.GetType().Name + "History");

ServiceLocationHistory history = adapter.Adapt&lt;ServiceLocation, historyType&gt;(modifiedEntry as ServiceLocation);
historyRepository.Add(history);
</code></pre>

<p>Edit:
I ended up doing this:</p>

<pre><code>ServiceLocationHistory history = adapter.GetType()
                                    .GetMethod("Adapt", new Type[] { typeof(ServiceLocation) })
                                    .MakeGenericMethod(typeof(ServiceLocation), typeof(ServiceLocationHistory))
                                    .Invoke(adapter, new object[] { modifiedEntry as ServiceLocation })
                                     as ServiceLocationHistory;
</code></pre>
