Book a Demo

Author Topic: How to "Import" .NET System.x classes ?  (Read 4032 times)

dmcomer

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • Been there, done that, back for more....
    • View Profile
How to "Import" .NET System.x classes ?
« on: September 20, 2007, 08:31:21 am »
Sorry for the vague subject. This is hopefully very simple. I am modeling a project where I want to include, in my sequence diagram, interaction with a .NET class. In this case System.Threading.SynchronizationContext which was referenced in the project when I extracted the code. I could simply create a new element (class) called SyncrhonicationContext, add the element to the activity diagram as an object and presto. The problem with that is I don't want the code engineering to create a new class when I synchronize my code (I'm using the Visual Studio Addin). I seem to recall seeing somewhere where you can "import" classes from .NET namespaces? Does anyone have advice or suggestions on a better way to represent a .NET class?

Thanks,

Dave Comer

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #1 on: September 20, 2007, 09:00:39 am »
create a package ( dotNet for example )
Right click on the package and select [Code Engineering | Import Binary Module ...]

Select the .net assembly, dll, etc that you want to import

Also you probably want to select "Do not import private members"

Jim

dmcomer

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • Been there, done that, back for more....
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #2 on: September 20, 2007, 09:48:01 am »
Jim,

Thanks for the quick reply. That worked. I appreciate your time.

Dave

dmcomer

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • Been there, done that, back for more....
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #3 on: September 20, 2007, 10:19:08 am »
Here a follow-up. Have you discovered a way to only import those classes that are used in your code? There is a "syncrhonize with code" radio button which I would think performs this function, but the manual does no describe the button's purpose not does it appear to synchronize the code.

Thanks,
Dave

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #4 on: September 20, 2007, 02:04:14 pm »
Best Regards, Roy

dmcomer

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • Been there, done that, back for more....
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #5 on: September 20, 2007, 04:13:49 pm »
Roy,

Thanks for taking time to reply. I ran across the section of the manual you referenced but discounted that method. The reason is the section you pointed out is forward code engineering only. I need to maintain forward and reverse compatible.

The solution I decided on is to take Jim's queue and import the dll (c:\<systemdir>\Microsoft.NET\<framework>\mscorlib.dll in my case) into a separate package. Then, drag the element (class/object) onto the diagram of choice in my project model. I'm not experienced enough, yet, with EA yet so I don't know if there is a link inserted behind the scenes, or how the namespace is communicated across packages, but it appears to work. If anyone else has a better idea or explanation, I'd be interested. I may send a support request to Sparx to see if they have input and suggest they consider adding an example (unless there is one that I missed).

Thanks,

Dave

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #6 on: September 20, 2007, 05:06:58 pm »
In answer to one of your previous posts, unfortunately there is no way to limit what you import from the .NET Assembly that I am aware.  I just tend to 'cancel' the import after a few minutes and it's usually imported the essentials by then.

Depending upon the element and diagram type, dragging an Element from the Project Browser should typically create a "Simple Link" to the element on your diagram.  Other available options are "as Instance (Object)", and "as Child (Generalization)".  To force this choice to appear, hold [ctrl] when dropping the element.

Just as another tip, you should make sure you set the root package that you imported your assembly under as a "Namespace Root".  This will make sure that all classes under that package should have the correct namespace definition.

HTH.

dmcomer

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • Been there, done that, back for more....
    • View Profile
Re: How to "Import" .NET System.x classe
« Reply #7 on: September 21, 2007, 04:48:45 pm »
Aaron,

Thanks for your reply. There are a few tips in there that I wasn't aware of that I will make use of. With respect to the import of .NET assembly binaries, I guess I could request a feature to filter on class, but it really isn't that big of a deal to use your suggestion. You know what would be nice is to be able to block select elements and be able to delete them all at once. To my knowledge this is not possible now and I end up moving the elements to a junk package and deleting the package.

With respect the namespace root, I haven't been paying attention to that but will in the future. Your [ctrl] tip on dropping elements is a nifty one as well.

So, thanks. I really am having allot of success with EA and am trying to get a project done as a demonstration of the power for peers in my company to see.

Thanks,

Dave