If the connectors are in different projects, this is easy to solve:
Add a new class file, call it ConnectorCommon and copy all the common code, but with the removal of namespaces. Make this class an incomplete class and rename the class (not the file) to something like Connector.
You will need to add a link to this for each project.
Then remove all the code from your current connector classes, rename the class (not necessarily the file) as well as the incomplete class, and add a using statement that references the namespace.
This should get what you are looking for.
So, when you are done, you will have:
File connector:
public partial class Connector { public void GetAllCustomers() { var _foo = new FooService(); customerEntity[] customers = _foo.getCustomerList; foreach (customerEntity customer in customers) { GetSingleCustomer(customer); } } public void GetSingleCustomer(customerEntity customer) { var id = customer.foo_id;
Magento15Connector File
using Foo15WebReference; partial class Connector { }
Magento14Connector File
using Foo14WebReference; partial class Connector { }
Update
This process can be a bit confusing at first.
To clarify, you share the source code in a shared file between two projects.
Actual classes are concrete classes with namespaces in each project. You use a partial keyword so that the common file is combined with the actual project file (i.e. Magneto14) in each project to create a complete class inside this project at compile time.
The hardest part is adding a shared file to both projects.
To do this, select the Add Existing Item... menu in the second project, navigate to the shared file and click the right arrow next to the Add button.
Select Add as link from the drop-down menu. This will add a link to the file in the second project. The source code will be included in both projects, and any changes in the shared file will be automatically available in both projects.
Update 2
I sometimes forget how easily VB performs such tasks, as it is a common programming environment.
To do this work in C #, you need to use another trick: Conditional compilation symbols . This makes the beginning of the generic code a little more verbose than I would like, but it still ensures that you can work with one set of generic code.
To use this trick, add a conditional compilation symbol to each project (make sure it is installed for All Configurations ). For example, in the Magento14 project Magento14 add Ver14 and in the Magento15 add Ver15 .
Then, in the shared file, replace the namespace with a structure similar to the following:
#if Ver14 using Magneto14; namespace Magento14Project #elif Ver15 using Magneto15; namespace Magento15Project #endif
This will ensure that the correct namespace and application is included based on the project into which the common code is compiled.
Please note that all regular using statements must be stored in a common file (i.e. enough to compile it).