title: Refactoring duplicate code when the only difference is the type of one variable?
body: <p>I have to be able to connect to two different versions of the an API (1.4 and 1.5), lets call it the Foo API. And my code that connects to the API and processes the results is substantially duplicated - the only difference is the data types returned from the two APIs.  How can I refactor this to remove duplication? </p>
  
  <p>In Foo14Connector.cs (my own class that calls the 1.4 API)</p>
  
  <pre><code>public class Foo14Connector
  {
      public void GetAllCustomers() 
      {
          var _foo = new Foo14WebReference.FooService();
          Foo14WebReference.customerEntity[] customers = _foo.getCustomerList;
          foreach (Foo14WebReference.customerEntity customer in customers)
          {
              GetSingleCustomer(customer);
          }
      }
      public void GetSingleCustomer(Foo14WebReference.customerEntity customer)
      {
          var id = customer.foo_id;
          // etc 
      }
  }
  </code></pre>
  
  <p>And in the almost exact duplicate class Foo15Connector.cs (my own class that calls the 1.5 API)</p>
  
  <pre><code>public class Foo15Connector
  {
      public void GetAllCustomers() 
      {
          var _foo = new Foo15WebReference.FooService();
          Foo15WebReference.customerEntity[] customers = _foo.getCustomerList;
          foreach (Foo15WebReference.customerEntity customer in customers)
          {
              GetSingleCustomer(customer);
          }
      }
      public void GetSingleCustomer(Foo15WebReference.customerEntity customer)
      {
          var id = customer.foo_id;
          // etc 
      }
  }
  </code></pre>
  
  <p>Note that I have to have two different connectors because one single method call (out of hundreds) on the API has a new parameter in 1.5.  </p>
  
  <p>Both classes Foo14WebReference.customerEntity and Foo15WebReference.customerEntity have identical properties.</p>