Book a Demo

Author Topic: Adding operators to class via Automation Interface  (Read 2890 times)

petgru

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Adding operators to class via Automation Interface
« on: June 19, 2007, 02:38:33 am »
Hi,

I'm working on a system that, when its done, is going to move information from Biztalk (about orchestrations and stuff) to EA for documentation purposes. Right now I'm playing around with the automation interface and trying to insert information into EA. Inserting several types of elements (like classes and objects) works fine, but I can't seem to be able to insert operators/methods and attributes.

The following code doesn't seem to do the trick:
element.Methods.AddNew(name,type);

How am supposed to do it? If this is the right method, what is supposed to be in the type field?

BTW, Is there any good documentation about using the EA API, I can't seem to find any.

Regards
Peter Grundström

ACSmith

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Adding operators to class via Automation Inter
« Reply #1 on: June 19, 2007, 04:52:03 am »
You'll need to capture a reference to the newly added attribute/operation/etc.  After you've set your properties, be sure to call the Update method on the newly created object.  There's a small (very small) reference to this in the documentation somewhere.  I found it after I had played with this and gotten many gray hairs.  Here's some example code in C#, hope this helps!

           EA.Attribute fieldAttribute = (element.Attributes.AddNew(name, type) as EA.Attribute);

           fieldAttribute.Stereotype = "XSDElement";
           fieldAttribute.Notes = xmlNotes;
           fieldAttribute.Type = type;
           fieldAttribute.Default = defaultValue;
           fieldAttribute.Update();