title: In an extension method how do a create an object based on the implementation class
body: <p>In an extension method how do a create an object based on the implementation class.  So in the code below I wanted to add an "AddRelationship" extension method, however I'm not sure how within the extension method I can create an Relationship object?  i.e. don't want to tie the extension method to this particular implementation of relationship</p>
  
  <pre><code>   public static class TopologyExtns
      {
  
          public static void AddNode&lt;T&gt;(this ITopology&lt;T&gt; topIf, INode&lt;T&gt; node)
          {
              topIf.Nodes.Add(node.Key, node);
          }
  
          public static INode&lt;T&gt; FindNode&lt;T&gt;(this ITopology&lt;T&gt; topIf, T searchKey)
          {
              return topIf.Nodes[searchKey];
          }
  
          public static bool AddRelationship&lt;T&gt;(this ITopology&lt;T&gt; topIf, INode&lt;T&gt; parentNode, INode&lt;T&gt; childNode)
          {
              var rel = new RelationshipImp();  // ** How do I create an object from teh implementation 
              // Add nodes to Relationship
              // Add relationships to Nodes
          }
      }
  
  
      public interface ITopology&lt;T&gt;
      {
          //List&lt;INode&gt; Nodes { get; set; }
          Dictionary&lt;T, INode&lt;T&gt; &gt; Nodes { get; set; }
      }
  
      public interface INode&lt;T&gt; 
      {
          // Properties
          List&lt;IRelationship&lt;T&gt;&gt; Relationships { get; set; }
          T Key { get; }
      }
  
      public interface IRelationship&lt;T&gt;
      {
          // Parameters
          INode&lt;T&gt; Parent { get; set; }
          INode&lt;T&gt; Child { get; set; }
      }
  
  
  namespace TopologyLibrary_Client
  {
  
      class RelationshipsImp : IRelationship&lt;string&gt;
      {
          public INode&lt;string&gt; Parent { get; set; }
          public INode&lt;string&gt; Child { get; set; }
      }
  }
  
      public class TopologyImp&lt;T&gt; : ITopology&lt;T&gt;
      {
          public Dictionary&lt;T, INode&lt;T&gt;&gt; Nodes { get; set; }
          public TopologyImp()
          {
              Nodes = new Dictionary&lt;T, INode&lt;T&gt;&gt;();
          }
  
      }
  </code></pre>
  
  <p>thanks</p>