1
Automation Interface, Add-Ins and Tools / Re: Creating C# Project from Exported XMI
« on: July 15, 2008, 04:23:12 am »
Ok. Question 2.
I have a package which I would like to add to a repository, the package contains sub-packages of the same XML layout.
To add a package to a repository it seems as though I would create an element, copy over a few parameters from the XML. Then for sub-packages, I would create sub-elements and link them.
So, I pass the XML package to an element constructor, create a EA.Element copy a few parameters (name, guid etc.) and then attempt to add an element to it's Elements collection, it seems as if I should be able to set this up recursively so that all the subpackages would be included in the EA.Element.Elements
This does not seem to work. EA.Element.Elements seems to have only one method for adding a new EA.Element to it's collection, but the parameters for the EA.Element.AddNew(string, string) are incorrect.
How are Elements meant to be added in such a case?
Here's some code
So, is there something that I can replace the comment with that will add this element to the elements collection?
I have a package which I would like to add to a repository, the package contains sub-packages of the same XML layout.
To add a package to a repository it seems as though I would create an element, copy over a few parameters from the XML. Then for sub-packages, I would create sub-elements and link them.
So, I pass the XML package to an element constructor, create a EA.Element copy a few parameters (name, guid etc.) and then attempt to add an element to it's Elements collection, it seems as if I should be able to set this up recursively so that all the subpackages would be included in the EA.Element.Elements
This does not seem to work. EA.Element.Elements seems to have only one method for adding a new EA.Element to it's collection, but the parameters for the EA.Element.AddNew(string, string) are incorrect.
How are Elements meant to be added in such a case?
Here's some code
Code: [Select]
namespace XMIMain
{
class Element
{
//element property
private EA.Element _element;
public EA.Element Element
{
get { return _element; }
}
//constructor
public Element(RegistryPackageType package)
{
_element = new EA.Element();
_element.Name = package.Name;
_element.ElementGUID = package.id;
foreach (IdentifiableType id in package.RegistryObjectList)
{
if (id is RegistryPackageType)
{
XMIMain.Element subElement = new XMIMain.Element((RegistryPackageType)id);
//in here we need to add this new element to the elements collection?
//_element.Elements.Add(subElement.Element)?
}
}
}
}
}
So, is there something that I can replace the comment with that will add this element to the elements collection?