Message 1 of 2
New idea for addin version management : Open for thoughts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Referring to this discussion:
https://forums.autodesk.com/t5/revit-api-forum/addin-version-management/m-p/7261164#M24280
I'd like to share with you more efficient way to keep only one installer for all Revit versions and same dll file as well.
I used dependency Inversion principle and worked nice for this purpose.
here's the code sample:
class PlaneFactory : IPlaneCreator { Application _app; IPlaneCreator creator16; IPlaneCreator creator17; public PlaneFactory(Application app) { _app = app; creator16 = new PlaneCreator16(_app); creator17 = new PlaneCreator17(); } public Plane CreatePlaneByInputs(XYZ Origin, XYZ vx, XYZ vy) { if (Convert.ToInt32(_app.VersionNumber) > 2016.5) { return creator17.CreatePlaneByInputs(Origin, vx, vy); } else { return creator16.CreatePlaneByInputs(Origin, vx, vy); } } public Plane CreatPlane() { if (Convert.ToInt32(_app.VersionNumber) > 2016.5) { return creator17.CreatPlane(); } else { return creator16.CreatPlane(); } } }
I would like to see if you have different thoughts or ideas.
Thanks, Ibrahim Naeem