public static string GetClassifierName(this EAAPI.Element element, EAAPI.Repository repository) { string result = ""; int classiferID = 0; if (element.Type == "Port" || element.Type == "Part" || element.Type == "ActionPin") { classiferID = element.PropertyType; } else { classiferID = element.ClassifierID; } if (classiferID != 0) { EAAPI.Element classifierElement = repository.GetElementByID(classiferID); if (classifierElement != null) { result = classifierElement.Name; } } return(result); }
public static EAAPI.Element AddEmbeddedElement(this EAAPI.Element parent, EAAPI.Repository repository, string name, string type) { EAAPI.Element result = null; if (string.IsNullOrEmpty(name)) { name = "empty"; } if (parent.Type == "Package") { EAAPI.Package package = repository.GetPackageByGuid(parent.ElementGUID) as EAAPI.Package; result = package.AddElement(name, type); } else { EAAPI.Element newElement = (EAAPI.Element)parent.Elements.AddNew(name, type); if (!newElement.Update()) { Debug.WriteLine(newElement.GetLastError()); } parent.Elements.Refresh(); result = newElement; } return(result); }
public static EAAPI.Package GetModelPackage(this EAAPI.Package package, EAAPI.Repository repository) { EAAPI.Package result = package; while (result.ParentID != 0) { result = repository.GetPackageByID(result.ParentID); } return(result); }
public static EAAPI.Element GetClassifier(this EAAPI.Attribute attribute, EAAPI.Repository repository) { EAAPI.Element result = null; if (attribute.ClassifierID != 0) { result = repository.GetElementByID(attribute.ClassifierID); } return(result); }
public static string GetClassifierName(this EAAPI.Attribute attribute, EAAPI.Repository repository) { string result = ""; if (attribute.ClassifierID != 0) { result = repository.GetElementByID(attribute.ClassifierID).Name; } else if (attribute.ClassifierID == 0 && !string.IsNullOrEmpty(attribute.Type)) { result = attribute.Type; } return(result); }
public static EAAPI.Element GetClassifier(this EAAPI.Method method, EAAPI.Repository repository) { EAAPI.Element result = null; int classifierID = 0; if (int.TryParse(method.ClassifierID, out classifierID)) { if (classifierID != 0) { result = repository.GetElementByID(classifierID); } } return(result); }
public static void DeletePackage(this EAAPI.Repository repository, EAAPI.Package package) { EAAPI.Package parent = repository.GetPackageByID(package.ParentID); for (int i = 0; i < parent.Packages.Count; i++) { EAAPI.Package actP = (EAAPI.Package)parent.Packages.GetAt((short)i); if (actP.PackageID == package.PackageID) { parent.Packages.Delete((short)i); break; } } parent.Update(); //Repository.RefreshModelView(parent.PackageID); }
/// <summary> /// /// </summary> /// <param name=""></param> /// <param name="repository"></param> /// <param name="element"></param> /// <returns>The package ID.</returns> public static int DeleteElement(this EAAPI.Repository repository, EAAPI.Element element) { EAAPI.Package parentPackage = repository.GetPackageForElement(element); for (int i = 0; i < parentPackage.Elements.Count; i++) { EAAPI.Element el = (EAAPI.Element)parentPackage.Elements.GetAt((short)i); if (el.ElementID == element.ElementID) { parentPackage.Elements.Delete((short)i); break; } } parentPackage.Elements.Refresh(); parentPackage.Update(); return(parentPackage.PackageID); }
public static string GetClassifierName(this EAAPI.Method method, EAAPI.Repository repository) { string result = ""; int classifierID = 0; if (int.TryParse(method.ClassifierID, out classifierID)) { if (classifierID != 0) { result = repository.GetElementByID(classifierID).Name; } else { result = method.ReturnType; } } return(result); }
public static EAAPI.Element GetClassifier(this EAAPI.Element element, EAAPI.Repository repository) { EAAPI.Element result = null; int classiferID = 0; if (element.Type == "Port" || element.Type == "Part" || element.Type == "ActionPin") { classiferID = element.PropertyType; } else { classiferID = element.ClassifierID; } if (classiferID != 0) { result = repository.GetElementByID(classiferID); } return(result); }
public static void DeleteConnector(this EAAPI.Repository repository, EAAPI.Connector con) { EAAPI.Element element = repository.GetElementByID(con.ClientID); short index = -1; for (short i = 0; i < element.Connectors.Count; i++) { EAAPI.Connector c = element.Connectors.GetAt(i) as EAAPI.Connector; if (c.ConnectorID == con.ConnectorID) { index = i; break; } } if (index != -1) { element.Connectors.Delete(index); element.Connectors.Refresh(); } }
public static EAAPI.Package GetPackageForElement(this EAAPI.Repository repository, EAAPI.Element element) { return(repository.GetPackageByID(element.PackageID)); }
public static EAAPI.Element GetParentElement(this EAAPI.Element childElement, EAAPI.Repository repository) { return(repository.GetElementByID(childElement.ParentID)); }