本文整理汇总了C#中EA.GetElementByID方法的典型用法代码示例。如果您正苦于以下问题:C# EA.GetElementByID方法的具体用法?C# EA.GetElementByID怎么用?C# EA.GetElementByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EA
的用法示例。
在下文中一共展示了EA.GetElementByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetElementFromContextObject
/// <summary>
/// Get element from Context element. Possible inputs are: Attribute, Operation, Element, Package
/// </summary>
/// <param name="rep"></param>
/// <returns></returns>
public static EA.Element GetElementFromContextObject(EA.Repository rep) {
EA.Element el = null;
EA.ObjectType objectType = rep.GetContextItemType();
switch (objectType)
{
case ObjectType.otAttribute:
var a = (EA.Attribute)rep.GetContextObject();
el = rep.GetElementByID(a.ParentID);
break;
case ObjectType.otMethod:
var m = (Method)rep.GetContextObject();
el = rep.GetElementByID(m.ParentID);
break;
case ObjectType.otElement:
el = (EA.Element)rep.GetContextObject();
break;
case ObjectType.otPackage:
EA.Package pkg = rep.GetContextObject();
el = rep.GetElementByGuid(pkg.PackageGUID);
break;
case ObjectType.otNone:
EA.Diagram dia = rep.GetCurrentDiagram();
if (dia?.SelectedObjects.Count == 1)
{
var objSelected = (EA.DiagramObject)dia.SelectedObjects.GetAt(0);
el = rep.GetElementByID(objSelected.ElementID);
}
break;
default:
MessageBox.Show(@"No Element, Attribute, Operation, Package selected");
break;
}
return el;
}
示例2: changeAttributeVisibility
/// <summary>
/// method changes scope of attribute
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="attributeGUID">GUID of changed attribute</param>
/// <param name="scope">new scope of changed attribute</param>
/// <param name="oldScope">previous scope of changed attribute</param>
public void changeAttributeVisibility(EA.Repository Repository, string attributeGUID, string scope, string oldScope)
{
EA.Attribute attribute = (EA.Attribute)Repository.GetAttributeByGuid(attributeGUID);
attribute.Visibility = scope;
attribute.Update();
EA.Element element = (EA.Element)Repository.GetElementByID(attribute.ParentID);
BPAddIn.synchronizationWindow.addToList("Change of scope of attribute '" +
attribute.Name + "' - previous scope: '" + oldScope + "', current scope: '" + scope +
"' (Attribute of element '" + element.Name + "', location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
}
示例3: deleteConnector
/// <summary>
/// method deletes connector
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="connectorGUID">GUID of connector that should be deleted</param>
/// <param name="diagramGUID">GUID of diagram</param>
/// <param name="elementType">type of connector that should be deleted</param>
public void deleteConnector(EA.Repository Repository, string connectorGUID, string diagramGUID, int elementType)
{
EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
string name = connector.Name;
EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);
for (short i = 0; i < srcElement.Connectors.Count; i++)
{
EA.Connector conn = (EA.Connector)srcElement.Connectors.GetAt(i);
if (conn.ConnectorGUID == connectorGUID)
{
srcElement.Connectors.DeleteAt(i, false);
break;
}
}
srcElement.Connectors.Refresh();
BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '"
+ name + "' between element '" + srcElement.Name +
"' and element '" + targetElement.Name + "'");
}
示例4: UpdateActionPinParameter
//---------------------------------------------------------------------------------------------
// updateActionParameter(EA.Repository rep, EA.Element actionPin)
//---------------------------------------------------------------------------------------------
public static bool UpdateActionPinParameter(EA.Repository rep, EA.Element action)
{
foreach (EA.Element actionPin in action.EmbeddedElements)
{
// pin target for the return type of the action
if (actionPin.Name == "target")
{
//// return type
//Int32 parTypeID = Util.getTypeID(rep, m.ReturnType);
//if (parTypeID != 0)
//{
// //pin.Name = par.
// pin.ClassfierID = parTypeID;
// EA.Element el = rep.GetElementByID(parTypeID);
// pin.Update(); // do it before update table
// Util.setElementPDATA1(rep, pin, el.ElementGUID);// set PDATA1
//}
}
else
{
// get type of synchronized parameter
// if parameter isn't synchronized it will not work
string type = Util.GetParameterType(rep, actionPin.ElementGUID);
if (type == "")
{
string txt = "No type is available for action:'" + action.Name + "'";
rep.WriteOutput("ifm_addin", txt, 0);
}
else
{
Int32 parTypeId = Util.GetTypeId(rep, type);
if (parTypeId != 0)
{
//pin.Name = par.
EA.Element el = rep.GetElementByID(parTypeId);
Util.SetElementPdata1(rep, actionPin, el.ElementGUID);// PDATA1 setzen
}
}
}
}
return true;
}
示例5: deleteAttribute
/// <summary>
/// method deletes attribute from element
/// </summary>
/// <param name="Repository">EA repository</param>
/// <param name="attributeGUID">GUID of attribute that should be deleted</param>
public void deleteAttribute(EA.Repository Repository, string attributeGUID)
{
EA.Attribute attribute = (EA.Attribute)Repository.GetAttributeByGuid(attributeGUID);
string name = attribute.Name;
EA.Element element = (EA.Element)Repository.GetElementByID(attribute.ParentID);
for (short i = 0; i < element.Attributes.Count; i++)
{
EA.Attribute actualAttribute = (EA.Attribute)element.Attributes.GetAt(i);
if (actualAttribute.AttributeGUID == attributeGUID)
{
element.Attributes.DeleteAt(i, false);
break;
}
}
element.Attributes.Refresh();
BPAddIn.synchronizationWindow.addToList("Deletion of attribute '" + name + "' from element '" + element.Name
+ "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
}
示例6: GetCurrentElement
/// <summary>
/// Selected items in the project browser are processed differently than selected elements
/// in the visible diagram. This helper will grab the currently selected project browser item first.
/// If it doesn't find it, it will return the currently selected diagram item.
/// </summary>
/// <param name="repository">The currently open EA repository</param>
/// <returns>The element currently selected in either the project browser or diagram</returns>
public static EA.Element GetCurrentElement(EA.Repository repository)
{
EA.Element result = null;
EA.Collection elements = repository.GetTreeSelectedElements();
if (elements.Count > 0)
{
result = elements.GetAt(0);
}
else
{
EA.Diagram diagram = repository.GetCurrentDiagram();
if (diagram != null)
{
EA.DiagramObject s = diagram.SelectedObjects.GetAt(0);
result = repository.GetElementByID(s.ElementID);
}
}
return result;
}
示例7: DoRule09
private void DoRule09(EA.Repository Repository, EA.Connector Connector)
{
EA.Project Project = Repository.GetProjectInterface();
EA.Element client = Repository.GetElementByID(Connector.ClientID);
EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);
if (Connector.Stereotype == "XisEntityInheritance"
&& (client.Stereotype != "XisEntity" || supplier.Stereotype != "XisEntity"))
{
Project.PublishResult(LookupMap(rule09), EA.EnumMVErrorType.mvError, GetRuleStr(rule09));
isValid = false;
}
}
示例8: DoRule89_to_93
private void DoRule89_to_93(EA.Repository Repository, EA.Element Element, string stereotype)
{
if (Element.Type == "Class" && Element.Stereotype == stereotype)
{
string entityName = M2MTransformer.GetTaggedValue(Element.TaggedValues, "entityName").Value;
if (!string.IsNullOrEmpty(entityName))
{
EA.Element space = null;
EA.Element el = null;
EA.Connector conn = null;
EA.Connector assoc = null;
bool publishResult = false;
int parentID = Element.ParentID;
while (parentID > 0)
{
el = Repository.GetElementByID(parentID);
if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
{
space = el;
break;
}
parentID = el.ParentID;
}
if (space == null && stereotype == "XisMenu")
{
EA.Element end = null;
for (short i = 0; i < Element.Connectors.Count; i++)
{
conn = Element.Connectors.GetAt(i);
if (conn.ClientID != Element.ElementID)
{
end = Repository.GetElementByID(conn.ClientID);
}
else
{
end = Repository.GetElementByID(conn.SupplierID);
}
if (conn.Stereotype == "XisIS-MenuAssociation")
{
if (end.Stereotype == "XisInteractionSpace")
{
space = end;
break;
}
else
{
parentID = end.ParentID;
while (parentID > 0)
{
el = Repository.GetElementByID(parentID);
if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
{
space = el;
break;
}
parentID = el.ParentID;
}
}
}
}
}
if (space != null)
{
for (short i = 0; i < space.Connectors.Count; i++)
{
conn = space.Connectors.GetAt(i);
if (conn.Stereotype == "XisIS-BEAssociation")
{
assoc = conn;
break;
}
}
if (assoc != null)
{
EA.Element be = Repository.GetElementByID(assoc.SupplierID);
bool hasEntity = false;
if (be.Stereotype == "XisBusinessEntity" && be.Connectors.Count > 0)
{
EA.Element entity = null;
for (short i = 0; i < be.Connectors.Count; i++)
{
conn = be.Connectors.GetAt(i);
if (conn.Stereotype == "XisBE-EntityMasterAssociation"
|| conn.Stereotype == "XisBE-EntityDetailAssociation"
|| conn.Stereotype == "XisBE-EntityReferenceAssociation")
//.........这里部分代码省略.........
示例9: DoRule96_97
private void DoRule96_97(EA.Repository Repository, EA.Element Element, string filter)
{
if (Element.Type == "Class" && Element.Stereotype == "XisList")
{
string domainRef = M2MTransformer.GetTaggedValue(Element.TaggedValues, filter).Value;
if (!string.IsNullOrEmpty(domainRef) && domainRef.Contains('.'))
{
bool publishResult = false;
string[] values = domainRef.Split('.');
if (values.Length == 2)
{
EA.Element space = null;
EA.Element el = null;
EA.Connector conn = null;
EA.Connector assoc = null;
int parentID = Element.ParentID;
while (parentID > 0)
{
el = Repository.GetElementByID(parentID);
if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
{
space = el;
break;
}
parentID = el.ParentID;
}
if (space != null)
{
for (short i = 0; i < space.Connectors.Count; i++)
{
conn = space.Connectors.GetAt(i);
if (conn.Stereotype == "XisIS-BEAssociation")
{
assoc = conn;
break;
}
}
if (assoc != null)
{
EA.Element be = Repository.GetElementByID(assoc.SupplierID);
bool hasEntity = false;
if (be.Stereotype == "XisBusinessEntity" && be.Connectors.Count > 0)
{
EA.Element entity = null;
for (short i = 0; i < be.Connectors.Count; i++)
{
conn = be.Connectors.GetAt(i);
if (conn.Stereotype == "XisBE-EntityMasterAssociation"
|| conn.Stereotype == "XisBE-EntityDetailAssociation"
|| conn.Stereotype == "XisBE-EntityReferenceAssociation")
{
entity = Repository.GetElementByID(conn.SupplierID);
if (entity.Type == "Class" && entity.Stereotype == "XisEntity"
&& entity.Name == values[0])
{
hasEntity = true;
break;
}
}
}
if (hasEntity && entity.Attributes.Count > 0)
{
bool attrExists = false;
EA.Attribute attr = null;
for (short i = 0; i < entity.Attributes.Count; i++)
{
attr = entity.Attributes.GetAt(i);
if (attr.Stereotype == "XisEntityAttribute" && attr.Name == values[1])
{
attrExists = true;
break;
}
}
if (!attrExists)
{
publishResult = true;
}
}
else
{
publishResult = true;
}
}
else
{
//.........这里部分代码省略.........
示例10: annotateWithCDE
public static void annotateWithCDE(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.dataelement de)
{
object item;
const string CDEREF = "CDERef";
const string PREFNAME = "preferred name";
try
{
string id = de.names.id;
string name = de.names.preferred;
EA.ObjectType type = m_Repository.GetTreeSelectedItem(out item);
if (type != EA.ObjectType.otAttribute)
{
MessageBox.Show("No class attribute has been selected in the Project Browser", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
EA.Attribute attr = (EA.Attribute)item;
//string txt = "Container["+attr.Container;
//txt += "]\nContainment["+attr.Containment;
//txt += "]\nDefault["+attr.Default;
//txt += "]\nParentID["+attr.ParentID;
//txt += "]\nPos["+attr.Pos;
//txt += "]\nStereotype["+attr.Stereotype;
//txt += "]\nStereotypeEx["+attr.StereotypeEx;
//txt += "]\nStyle["+attr.Style;
//txt += "]\nStyleEx["+attr.StyleEx;
//txt += "]\n";
//MessageBox.Show(txt);
EA.Collection tvs = attr.TaggedValues;
if (tagExists(attr.TaggedValues, CDEREF))
{
//DialogResult dg = MessageBox.Show(
// el.Name + " already has a " + CDEREF + " annotation. Replace?",
// "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
//if (dg == DialogResult.Cancel)
// return;
MessageBox.Show(attr.Name + " already has a " + CDEREF + " annotation. Please remove and try again.");
return;
}
if (tagExists(attr.TaggedValues, PREFNAME))
{
MessageBox.Show(attr.Name + " already has a " + PREFNAME + " annotation. Please remove and try again.");
return;
}
EAUtil.addTaggedValue(CDEREF, id, attr);
EAUtil.addTaggedValue(PREFNAME, name, attr);
//
// All done, just display a successful message window
//
string attrName = "";
EA.Element pel = m_Repository.GetElementByID(attr.ParentID);
if (pel != null && pel.Name != null && pel.Name.Length > 0)
attrName = pel.Name + ".";
attrName += attr.Name;
MessageBox.Show("Attribute [" + attrName + "] successfully annotated with:\n\n"
+ CDEREF + " => " + id + "\n"
+ PREFNAME + " => " + name + "\n",
"Success",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch(Exception exp)
{
MessageBox.Show("Error annotating with CDE. " + exp.Message);
}
}
示例11: DoRule87
private void DoRule87(EA.Repository Repository, EA.Method method)
{
if (method.Stereotype == "XisAction")
{
string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value;
if (type == "Navigate")
{
string navigation = M2MTransformer.GetMethodTag(method.TaggedValues, "navigation").Value;
if (!string.IsNullOrEmpty(navigation))
{
EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID);
EA.Package interaction = null;
if (model.StereotypeEx == "InteractionSpace View")
{
interaction = model;
}
if (interaction != null)
{
EA.Element el = null;
bool exists = false;
for (short i = 0; i < interaction.Elements.Count; i++)
{
el = interaction.Elements.GetAt(i);
if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace" && el.Name == navigation)
{
exists = true;
break;
}
}
if (!exists)
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
isValid = false;
}
}
}
}
示例12: EA_OnPostNewDiagramObject
private Boolean EA_OnPostNewDiagramObject(EA.Repository repository, EA.EventProperties info)
{
outputTabActive(repository);
MessageBox.Show("NEW OBJECT CREATED");
EA.Element element = repository.GetElementByID(IDcollect(repository, info));
return true;
}
示例13: DoRule13
private void DoRule13(EA.Repository Repository, EA.Element Element)
{
if (Element.Type == "Class" && Element.Stereotype == "XisBusinessEntity")
{
if (Element.Connectors.Count > 0)
{
bool hasAssociation = false;
EA.Connector conn = null;
EA.Element supplier = null;
for (short i = 0; i < Element.Connectors.Count; i++)
{
conn = Element.Connectors.GetAt(i);
supplier = Repository.GetElementByID(conn.SupplierID);
if ((conn.Stereotype == "XisBE-EntityMasterAssociation"
|| conn.Stereotype == "XisBE-EntityDetailAssociation"
|| conn.Stereotype == "XisBE-EntityReferenceAssociation")
&& supplier.Stereotype == "XisEntity")
{
hasAssociation = true;
break;
}
}
if (!hasAssociation)
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule13), EA.EnumMVErrorType.mvError, GetRuleStr(rule13));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule13), EA.EnumMVErrorType.mvError, GetRuleStr(rule13));
isValid = false;
}
}
}
示例14: DoRule39
private void DoRule39(EA.Repository Repository, EA.Connector Connector)
{
if (Connector.Stereotype == "XisWidget-GestureAssociation")
{
EA.Element client = Repository.GetElementByID(Connector.ClientID);
EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);
if (supplier.Stereotype != "XisGesture" ||
(client.Stereotype != "XisLabel" && client.Stereotype != "XisTextBox" && client.Stereotype != "XisCheckBox"
&& client.Stereotype != "Button" && client.Stereotype != "Link" && client.Stereotype != "XisImage"
&& client.Stereotype != "XisDatePicker" && client.Stereotype != "XisTimePicker" && client.Stereotype != "XisDropdown"
&& client.Stereotype != "XisListItem" && client.Stereotype != "XisMenuItem"))
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule39), EA.EnumMVErrorType.mvError, GetRuleStr(rule39));
isValid = false;
}
}
}
示例15: DoRule50
private void DoRule50(EA.Repository Repository, EA.Element Element)
{
if (Element.Type == "Class" && Element.Stereotype == "XisMenu")
{
EA.TaggedValue menuType = M2MTransformer.GetTaggedValue(Element.TaggedValues, "type");
if (menuType != null && menuType.Value == "OptionsMenu")
{
if (Element.ParentID > 0)
{
EA.Element parent = Repository.GetElementByID(Element.ParentID);
if (parent.Stereotype != "XisInteractionSpace")
{
if (parent.Stereotype == "XisVisibilityBoundary" && parent.ParentID > 0)
{
parent = Repository.GetElementByID(parent.ParentID);
if (parent.Stereotype != "XisInteractionSpace")
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
isValid = false;
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
isValid = false;
}
}
}
else if (Element.Connectors.Count > 0)
{
EA.Connector conn = null;
EA.Element end = null;
for (short i = 0; i < Element.Connectors.Count; i++)
{
conn = Element.Connectors.GetAt(i);
if (conn.ClientID != Element.ElementID)
{
end = Repository.GetElementByID(conn.ClientID);
}
else
{
end = Repository.GetElementByID(conn.SupplierID);
}
if ((conn.Stereotype == "XisIS-MenuAssociation" && end.Stereotype != "XisInteractionSpace")
|| (conn.Stereotype != "XisIS-MenuAssociation" && end.Stereotype == "XisInteractionSpace"))
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
isValid = false;
break;
}
}
}
else
{
EA.Project Project = Repository.GetProjectInterface();
Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
isValid = false;
}
}
}
}