title: How to remove switch to convert string to generic function
body: <p>This is probably a newbie question but I couldn´t find a good answer even googling and reading a lot about the subject.</p>
  <p>I have a generic method, lets call it Execute()</p>
  <p>My code receives a message1:</p>
  <pre><code> {
     serviceProvider: &quot;Sever1&quot;,
     serviceType: &quot;query&quot;,
     service: &quot;authors&quot;
   }
  </code></pre>
  <p>and message2 could be:</p>
  <pre><code> {
     serviceProvider: &quot;Sever2&quot;,
     serviceType: &quot;query&quot;,
     service: &quot;bookTitles&quot;
  }
  </code></pre>
  <p>Now, I have</p>
  <pre><code>public void ProcessMessage(Message message)
  {
     switch (message.service)
     {
        case &quot;authors&quot;:
          Execute&lt;Authors&gt;();
          break;
        case &quot;booTitle&quot;:
          Execute&lt;BookTitle&gt;();
          break;
     }
  }
  </code></pre>
  <p>I really don´t like this ProcessMessage method, as it does not look DRY at all. And if we add more types of services, then we need to keep adding to the switch.</p>
  <p>How should I implement this thing? Do I need reflection? I´d rather not use reflection as the ProcessMessage can be called thousands of times and reflection would probably add a lot of overhead.</p>