Book a Demo

Author Topic: Two Questions about Generating C# Code  (Read 3259 times)

Owl Saver

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
  • Never give up.
    • View Profile
Two Questions about Generating C# Code
« on: October 20, 2009, 11:21:54 am »
I am just starting to use EA to generate C# code and have two questions:

- I have an aggregation relationship between two classes. Based on this, EA generates a member attribute to hold it. But, when I synchronise the code and model, it adds this attribute to my model. Is there any way to have it know that the aggregation relationship represents this attribute and it does not need to add it in the model?

- I am using the System.IO package for IO. How do I get EA to generate the correct unsing statmen for this? My few tries have not worked. I have other external packages I will be using and would like to tell the code generator about them.

Take Care

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Two Questions about Generating C# Code
« Reply #1 on: October 21, 2009, 08:19:28 am »
1. It knows the aggregation represents this attribute (otherwise it would have created a new association) but there isn't any way to stop it creating the attribute.  This has been discussed in length, but in summary they are different views of the same thing.

2. If you press Ctrl+G on a single class there are fields for inserting using statements (I don't know if C# uses the bottom one, so just use the top one.)  The alternative to that is that you can create a quick model that shows the classes you are using in System.IO and linking to them.  Also, please be aware that these are not synchronised, they are only generated when creating the entire file.

Owl Saver

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
  • Never give up.
    • View Profile
Re: Two Questions about Generating C# Code
« Reply #2 on: October 21, 2009, 10:47:12 am »
Thanks for the response. I played around with it and you are right, it works correctly for the containership - I must have been dreaming before.

I made the model and that seems to work so far. I may try the Control G option to see how that works.

So far, I have been doing all the work in EA. I have even coded the methods in EA. So, I completely regenerate each time. So far, this works fone for me. I guess at some point in the future I will need to sync rather than completely regenerate.

Thanks