title: generic interfaces and polymorphism
body: <p>I have following code:</p>
  
  <pre><code>public abstract class Operand&lt;T&gt;
  {
      public T Value { get; protected set; }
  
      public bool IsEmpty { get; protected set; }
  
      public override string ToString()
      {
          return IsEmpty ? Value.ToString() : string.Empty;
      }
  }
  public class DoubleOperand : Operand&lt;Double&gt; {}
  
  public interface IOperandFactory&lt;T&gt;
      {
          Operand&lt;T&gt; CreateEmptyOperand();
          Operand&lt;T&gt; CreateOperand(T value);
      }
  
  public class DoubleFactory: IOperandFactory&lt;double&gt;
  {
      public Operand&lt;Double&gt; CreateEmptyOperand()
      {
          //implementation
      }
  
      public Operand&lt;Double&gt; CreateOperand(double value)
      {
          //implementation
      }
  }
  </code></pre>
  
  <p>I simlified code to just show the structure. 
  Now I need associationDictionary that will return <code>IOperandFactory</code> for required <code>Type</code>:
  Something like this: </p>
  
  <pre><code>var factoryDict = 
  new Dictionary&lt;Type, IOperandFactory&lt;&gt;&gt;() { { typeof(double), new DoubleFactory() } };
  </code></pre>
  
  <p>Could you help me to achieve it if it is possible?</p>