Author Topic: Code compatibility  (Read 1932 times)

0 Members and 1 Guest are viewing this topic.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Code compatibility
« on: February 01, 2010, 05:16:40 PM »
Hi,

Playing with custom osnaps, I discover some changes in the Glyph class between 2007 and 2010 versions.
With 2007, a class which inherits Glyph have to implement ViewportDraw(), with 2010 SubViewportDraw().

2007
Code: [Select]
public override void ViewportDraw(ViewportDraw vd)
2010
Code: [Select]
protected override void SubViewportDraw(ViewportDraw vd)
I solved the problem making two versions, but is there a way to have a single version in which, according to the current AutoCAD version, one or the other method is called (may be using a delegate) ?
« Last Edit: February 01, 2010, 05:50:40 PM by gile »
Speaking English as a French Frog

LE3

  • Guest
Re: Code compatibility
« Reply #1 on: February 12, 2010, 07:16:47 PM »
Make your newer version and named properly maybe with a prefix or suffix (solution18) and save it in the same location as your previous project version.

Then, add your existing project .csproj and rename it to for example solution17.

On your solution18 go to properties - build - conditional compilation symbols: and type your target symbol maybe: _ACADTARGET_18

Then on your code place it like:

#if (_ACADTARGET_18)
                const string APP_VER = "18"; // target A2010
#else
                const string APP_VER = "17"; // target A2007 trough A2009
#endif


Or on your assemblies:

#if (_ACADTARGET_18)
using System.Windows.Interop; // target A2010
#endif


Do your preferences calls/settings for each of your projects and you can erase the .sln extension of your previous solution version if you want - once you have all the setup you can run the build and will do both.


HTH.
« Last Edit: February 12, 2010, 10:11:32 PM by LE3 »