Book a Demo

Author Topic: Import Properties as Associations (c# version 10)  (Read 6241 times)

jimmym

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Import Properties as Associations (c# version 10)
« on: February 09, 2015, 11:09:37 pm »
Hi,

I am trying to import some c# code that contains associations using the IList interface.

Code: [Select]
public IList<Target> MyAssociationProperty { get; set; }
I have been battling to import (or export) an association that looks like this. How do I setup the source code import to create association links between the classes. If I cannot do that, how do I create an association in such a way that it generates this code?

Thanks
Regards
Craig.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Import Properties as Associations (c# version
« Reply #1 on: February 10, 2015, 09:07:38 am »
Look up Collection classes in the help.

1. C# properties, even automatic properties are imported as an operation in the model. That means they will never create an association.

2. Each language has an option called 'Additional Collection Classes'. This allows attributes with a template class to be represented as an association after import.

3. Each language has an option (actually 3) for collection classes to generate for associations with a multiplicity. Click the button on the C# options page and enter IList<#TYPE#> into the default field.

4. If you want to override that last one for an individual assocaition. Set the 'Member Type' property.

jimmym

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Import Properties as Associations (c# version
« Reply #2 on: February 10, 2015, 04:23:03 pm »
Hi,

Thanks for the prompt response.

Modelling properties as an operation is possibly the root cause of the problem. Ideally I would want properties to be treated as attributes rather than operations, and be able to model the associations.

I will give the attributes a try, but I suspect it's not really what I am after.

jimmym

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Import Properties as Associations (c# version
« Reply #3 on: February 11, 2015, 05:38:21 pm »
Quote
Look up Collection classes in the help.
1. C# properties, even automatic properties are imported as an operation in the model. That means they will never create an association.

Do you guys have any plans to change this? I understand that from a technical point of view what you have done is not incorrect.

It's just so much more convenient to represent properties as associations rather than operations.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Import Properties as Associations (c# version
« Reply #4 on: August 22, 2019, 03:47:35 pm »
Hello,

I'm reopening this thread as I'm facing the same issue with C# reverse:
- in the Main.cs class, I have the following: public IList<Class1> Class1List { get; } = new List<Class1>();
- running the reverse, this is available as a property -> Class1List() : IList(Class1)
I need an association from Main to Class1 so the developer can easily find the linked classes to document the design/code.

I followed the recommendations below without any luck; actually I didn't find how to set the Member Type property in [4].

Look up Collection classes in the help.
1. C# properties, even automatic properties are imported as an operation in the model. That means they will never create an association.
2. Each language has an option called 'Additional Collection Classes'. This allows attributes with a template class to be represented as an association after import.
3. Each language has an option (actually 3) for collection classes to generate for associations with a multiplicity. Click the button on the C# options page and enter IList<#TYPE#> into the default field.
4. If you want to override that last one for an individual assocaition. Set the 'Member Type' property.

The only workaround on this would be a script to process all property operations, find a matching class, and create an association accordingly. Would such a script be available somewhere?

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com