Use one code base for AutoCAD and BricsCAD

BricsCAD form BricsSys supports the same API as AutoCAD from Autodesk. Same API but not the same interface. So how is it possible to use just one code base and support both cad systems?

First create a configuration for AutoCAD Debug and BricsCAD DebugBricsCAD. This will make it easy to start either AutoCAD or BricsCAD from Visual Studio as you can define which program should start in the project properties:
Settings To switch the interfaces in you source code you have to change the using statements depending on the cad system you want to use.
You can manage this with preprocessor statements:

using Teigha.DatabaseServices;
using Teigha.Runtime;
using Teigha.Geometry;

using Bricscad.ApplicationServices;
using Bricscad.Runtime;
using Bricscad.EditorInput;
using Application = Bricscad.ApplicationServices.Application;
using Platform = Bricscad;
using PlatformDB = Teigha;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows;
using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application;
using Platform = Autodesk.AutoCAD;
using PlatformDB = Autodesk.AutoCAD;

To switch the configuration you need to define the symbol BRICSCAD.
Go to project properties -> Build -> General -> Conditional compilation symbols and add BRICSCAD there. Make sure that the configuration DebugBricsCAD is selected. If you like you can add AUTOCAD as conditional compilation symbol to the Debug configuration. As we do not check this value it is not required here but if you later want to support nanoCAD from neosoft you might need it for the #elseif.
Constant By doing this the conditional compilation symbol is added in the project file (.proj) to the tag <DefineConstants> and it will be used for the preprocessor statements.

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugBricsCAD|AnyCPU'">

Now you can start your implementation with one code base and start the cad systems as you like by just switching the configuration Debug and DebugBricsCAD.