.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Best practice with MVVM

1 REPLY 1
Reply
Message 1 of 2
andreiim
756 Views, 1 Reply

Best practice with MVVM

I'm on a project that will have about a dozen of commands. Where should I put them?

 

For each viewmodel I have a view and a main model.

My commands only show the views, so it would make sense to be in the View part of the MVVM. But, if I put the command in the view's codebehind, autocad would instantiate the view for the whole lifetime of the document and I don't want this.

If I create a separate class for each command using a naming system like NameOfTheViewCommand, then I would practically have an MVVMC pattern, where C stand for command.

Or maybe I should create a class which includes all my commands and nothing else?

Or maybe all these approaches are wrong and there's already a well-established pattern known only by Autocad .NET experts and one of these gurus is kind enough to provide a best practice guide for this matter?

Tags (1)
1 REPLY 1
Message 2 of 2
fenton.webb
in reply to: andreiim

in terms of AutoCAD, we have a 3 level split...

 

1) Dependency on acad.exe

   - define your commands that rely on the AutoCAD UI here

2) Dependency on accore.dll

  - define your commands that only require the command line to work

3) Dependency on acdb19.dll

  - define your DWG manipulate code here

 

I recommend that all of your commands define a UI version and a non-UI version - e.g. LAYER (UI) -LAYER command line only. Your UI version should be in a DLL which references acmgd.dll (acad.exe), acdbmgd.dl (acdb19.dlll and accoremgd.dll (accore.dll)

 

I recommend that all of your -LAYER defined commands should be in a DLL which references accoremgd.dll, acdbmgd.dll

 

I recommend all of your DB related functionality reside in a DLL which references acdbmgd.dll.

 

Doing this will ensure:

 

1) Your commands can be scripted

2) Your commands will work on the cloud

3) Your code will work in other non-AutoCAD DWG hostable applications (RealDWG enabled)




Fenton Webb
AutoCAD Engineering
Autodesk

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost