本文整理汇总了C#中Repository.GetPackageByID方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetPackageByID方法的具体用法?C# Repository.GetPackageByID怎么用?C# Repository.GetPackageByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.GetPackageByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenIDL_GetFullPackageName
private static String GenIDL_GetFullPackageName(Repository repository, Element elem)
{
String packageName = "";
int packageID = elem.PackageID;
Package package = repository.GetPackageByID(packageID);
int parentPackageID = package.ParentID;
while (parentPackageID != 0)
{
packageName = IDL_NormalizeUserDefinedClassifierName(package.Name) + "::" + packageName;
packageID = parentPackageID;
package = repository.GetPackageByID(packageID);
parentPackageID = package.ParentID;
}
return packageName;
}
示例2: GenIDL_Attributes
/* Generate the IDL for an attribute.
* The attribute can appear by itself, a sequence, or an array.
* The determination of this is based on the settings of LowerBound and UpperBound
*
* UpperBound == 0 ==> Unbounded Sequence
* LowerBound == UpperBound == 1 ==> Single member (no Array/Sequence)
* LowerBound == 0 && UpperBound == 1 ==> Optional single member
*
* LowerBound < UpperBound (other values) ==> Bounded Sequence
* LowerBound == UpperBound (other values) == > Array
*
* returns true if it outputs some attribute; otherwise returns false
*/
private static bool GenIDL_Attributes(Repository repository, Element classElem, TextOutputInterface output, int depth)
{
if (classElem.Attributes.Count == 0)
{
return false;
}
foreach (EA.Attribute child in classElem.Attributes)
{
// This does not get the fully qualified type name. We need that to fully resolve
// the type in the IDL...
String typeName;
/* This code was trying to get the fully-qualified name but it throws an exception
*/
if ( child.ClassifierID == 0 ) {
typeName = IDL_NormalizeMemberTypeNameClassiffiedID0(child.Type);
}
else {
Element attributeType = repository.GetElementByID(child.ClassifierID);
Package attributePackage = repository.GetPackageByID(attributeType.PackageID);
typeName = GenIDL_GetFullPackageName(repository, attributeType)
+ IDL_NormalizeMemberTypeName(attributeType.Name);
}
//DEBUG::
if (typeName.Equals("dateTime") )
{
output.OutputTextLine(depth, "//DEBUG: typeName= " + typeName + " classifiedId= " + child.ClassifierID);
}
int lower = 0;
int upper = 0;
try {
lower = Convert.ToInt32(child.LowerBound);
} catch (Exception) {}
try {
upper = Convert.ToInt32(child.UpperBound);
} catch (Exception) { }
int attributeDepth = depth;
String effectiveTypeName = typeName;
String effectiveMemberName = child.Name;
String extraAnnotation = null;
if (upper == 0) // Unbounded sequence
{
//output.OutputText(attributeDepth, "sequence<" + typeName + "> " + child.Name + ";");
effectiveTypeName = "sequence<" + typeName + ">";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to unbounded sequence because (upper bound == 0)");
}
}
else if (lower == upper)
{
if (upper != 1) // Array
{
effectiveMemberName = child.Name + "[" + child.UpperBound + "]";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to array because (lower bound == upper bound)");
}
}
}
else if (lower == 0 && upper == 1)
{
// Handle this the same as an @optional annotation
extraAnnotation = "Optional";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to optional because (lower bound == 0 && upper bound == 1)");
}
}
else // bounded sequence
{
effectiveTypeName = "sequence<" + typeName + "," + child.UpperBound + ">";
if (idlMappingDetail >= IDLMappingDetail.IDL_DETAILS_FULL)
{
output.OutputTextLine(depth, "// Mapping to bounded sequence because (lower bound < upper bound)");
}
}
GenIDL_AttributeWithAnnotations(child, effectiveTypeName, effectiveMemberName, extraAnnotation, output, depth);
output.OutputTextLine();
//.........这里部分代码省略.........
示例3: handleDiagramCreation
public void handleDiagramCreation(Repository repository, int diagramID)
{
try
{
changed = false;
EA.Diagram diagram = repository.GetDiagramByID(diagramID);
ItemCreation itemCreation = new ItemCreation();
itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
itemCreation.itemGUID = diagram.DiagramGUID;
itemCreation.elementType = itemTypes.getDiagramType(diagram.DiagramGUID);
itemCreation.author = diagram.Author;
itemCreation.name = diagram.Name;
itemCreation.parentGUID = "0";
if (diagram.ParentID != 0)
{
EA.Element parent = repository.GetElementByID(diagram.ParentID);
if (parent != null)
{
itemCreation.parentGUID = parent.ElementGUID;
}
}
EA.Package package = repository.GetPackageByID(diagram.PackageID);
if (package != null)
{
itemCreation.packageGUID = package.PackageGUID;
}
changeService.saveChange(itemCreation);
}
catch (Exception ex) { }
}
示例4: handleElementCreation
public void handleElementCreation(Repository repository, int elementID)
{
try {
changed = false;
EA.Element el = repository.GetElementByID(elementID);
currentItem = el;
ItemCreation itemCreation = new ItemCreation();
itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
itemCreation.itemGUID = el.ElementGUID;
itemCreation.elementType = itemTypes.getElementType(el.ElementGUID);
itemCreation.author = el.Author;
itemCreation.name = el.Name;
itemCreation.parentGUID = "0";
if (itemTypes.getElementType(el.ElementGUID) != 6 &&
(itemTypes.getElementType(el.ElementGUID) < 30 || itemTypes.getElementType(el.ElementGUID) > 44))
{
if (el.ParentID != 0)
{
EA.Element parent = repository.GetElementByID(el.ParentID);
if (parent != null)
{
itemCreation.parentGUID = parent.ElementGUID;
}
}
}
EA.Package package = repository.GetPackageByID(el.PackageID);
if (package != null)
{
itemCreation.packageGUID = package.PackageGUID;
}
changeService.saveChange(itemCreation);
if (el.Type == "UseCase")
{
currentExtensionPoints.Add(el.ElementGUID, el.ExtensionPoints);
}
}
catch (Exception ex) { }
}
示例5: handlePackageCreation
public void handlePackageCreation(Repository repository, int packageID)
{
try
{
changed = false;
EA.Package package = repository.GetPackageByID(packageID);
currentPackage = package;
ItemCreation itemCreation = new ItemCreation();
itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
itemCreation.itemGUID = package.PackageGUID;
itemCreation.elementType = 3;
itemCreation.author = package.Element.Author;
itemCreation.name = package.Name;
itemCreation.parentGUID = "0";
EA.Package parentPackage = repository.GetPackageByID(package.ParentID);
if (parentPackage != null)
{
itemCreation.packageGUID = parentPackage.PackageGUID;
}
changeService.saveChange(itemCreation);
}
catch (Exception ex) { }
}
示例6: handlePackageDeletion
public void handlePackageDeletion(Repository repository, int packageID)
{
try
{
changed = false;
EA.Package package = repository.GetPackageByID(packageID);
PropertyChange modelChange = new PropertyChange();
modelChange.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID;
modelChange.itemGUID = package.PackageGUID;
modelChange.elementType = 3;
modelChange.elementDeleted = 1;
changeService.saveChange(modelChange);
}
catch (Exception ex) { }
}
示例7: CreateActivityForOperationsInElement
private static void CreateActivityForOperationsInElement(Repository rep, Element el)
{
if (el.Locked) return;
Package pkg = rep.GetPackageByID(el.PackageID);
int treePos = pkg.Packages.Count + 1;
foreach (Method m1 in el.Methods)
{
// Create Activity
ActivityPar.CreateActivityForOperation(rep, m1, treePos);
treePos = treePos + 1;
}
}
示例8: AddDiagramNote
public static void AddDiagramNote(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
if (oType.Equals(ObjectType.otDiagram))
{
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
Package pkg = rep.GetPackageByID(dia.PackageID);
if (pkg.IsProtected || dia.IsLocked) return;
// save diagram
rep.SaveDiagram(dia.DiagramID);
Element elNote;
try
{
elNote = (Element) pkg.Elements.AddNew("", "Note");
elNote.Update();
pkg.Update();
}
catch
{
return;
}
// add element to diagram
// "l=200;r=400;t=200;b=600;"
// get the position of the Element
int left = (dia.cx/2) - 100;
int right = left + 200;
int top = dia.cy - 150;
int bottom = top + 120;
//int right = diaObj.right + 2 * (diaObj.right - diaObj.left);
string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
var diaObject = (DiagramObject) dia.DiagramObjects.AddNew(position, "");
dia.Update();
diaObject.ElementID = elNote.ElementID;
diaObject.Update();
pkg.Elements.Refresh();
Util.SetDiagramHasAttchaedLink(rep, elNote);
rep.ReloadDiagram(dia.DiagramID);
}
}
示例9: GetContextPackage
//--------------------------------------------------------------------------------
/// <summary>
/// Get context Package from Package, Element, Diagram
/// </summary>
/// <param name="rep"></param>
/// <returns></returns>
static Package GetContextPackage(Repository rep)
{
switch (rep.GetContextItemType())
{
case ObjectType.otPackage:
return (Package) rep.GetContextObject();
case ObjectType.otElement:
Element el = (Element) rep.GetContextObject();
return rep.GetPackageByID(el.PackageID);
case ObjectType.otDiagram:
Diagram dia = (Diagram) rep.GetContextObject();
return rep.GetPackageByID(dia.PackageID);
default:
return null;
}
}
示例10: CreateActivityForOperation
public static void CreateActivityForOperation(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
switch (oType)
{
case ObjectType.otMethod:
var m = (Method) rep.GetContextObject();
// Create Activity at the end
Element el = rep.GetElementByID(m.ParentID);
Package pkg = rep.GetPackageByID(el.PackageID);
int pos = pkg.Packages.Count + 1;
ActivityPar.CreateActivityForOperation(rep, m, pos);
rep.Models.Refresh();
rep.RefreshModelView(0);
rep.ShowInProjectView(m);
break;
case ObjectType.otElement:
el = (Element) rep.GetContextObject();
if (el.Locked) return;
CreateActivityForOperationsInElement(rep, el);
rep.Models.Refresh();
rep.RefreshModelView(0);
rep.ShowInProjectView(el);
break;
case ObjectType.otPackage:
pkg = (Package) rep.GetContextObject();
CreateActivityForOperationsInPackage(rep, pkg);
// update sort order of packages
rep.Models.Refresh();
rep.RefreshModelView(0);
rep.ShowInProjectView(pkg);
break;
}
}
示例11: CreateTypeDefStructFromTextService
// ReSharper disable once UnusedMember.Global
// dynamical usage as configurable service by reflection
public static void CreateTypeDefStructFromTextService(Repository rep, string txt)
{
try
{
Cursor.Current = Cursors.WaitCursor;
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return;
Package pkg = rep.GetPackageByID(dia.PackageID);
if (dia.SelectedObjects.Count != 1) return;
var el = Util.GetElementFromContextObject(rep);
// delete comment
txt = DeleteComment(txt);
// delete macros
txt = Regex.Replace(txt, @"^[\s]*#[^\n]*\n", "", RegexOptions.Multiline);
MatchCollection matches = Regex.Matches(txt, @".*?}[\s]*[A-Za-z0-9_]*[\s]*;", RegexOptions.Singleline);
foreach (Match match in matches)
{
CreateTypeDefStructFromText(rep, dia, pkg, el, match.Value);
}
Cursor.Current = Cursors.Default;
}
catch (Exception e10)
{
MessageBox.Show(e10.ToString(), @"Error insert Attributes");
}
finally
{
Cursor.Current = Cursors.Default;
}
}
示例12: LocateType
/// <summary>
/// Locate the type for Connector, Method, Attribute, Diagram, Element, Package
/// </summary>
/// <param name="rep"></param>
public static void LocateType(Repository rep)
{
ObjectType oType = rep.GetContextItemType();
Element el;
int id;
string triggerGuid;
// connector
// links to trigger
switch (oType)
{
case ObjectType.otConnector:
var con = (Connector) rep.GetContextObject();
triggerGuid = Util.GetTrigger(rep, con.ConnectorGUID);
if (triggerGuid.StartsWith("{", StringComparison.Ordinal) &&
triggerGuid.EndsWith("}", StringComparison.Ordinal))
{
Element trigger = rep.GetElementByGuid(triggerGuid);
if (trigger != null) rep.ShowInProjectView(trigger);
}
else
{
SelectBehaviorFromConnector(rep, con, DisplayMode.Method);
}
break;
case ObjectType.otMethod:
var m = (Method) rep.GetContextObject();
if (m.ClassifierID != "")
{
id = Convert.ToInt32(m.ClassifierID);
// get type
if (id > 0)
{
el = rep.GetElementByID(id);
rep.ShowInProjectView(el);
}
}
break;
case ObjectType.otAttribute:
var attr = (EA.Attribute) rep.GetContextObject();
id = attr.ClassifierID;
// get type
if (id > 0)
{
el = rep.GetElementByID(attr.ClassifierID);
if (el.Type.Equals("Package"))
{
Package pkg = rep.GetPackageByID(Convert.ToInt32(el.MiscData[0]));
rep.ShowInProjectView(pkg);
}
else
{
rep.ShowInProjectView(el);
}
}
break;
// Locate Diagram (e.g. from Search Window)
case ObjectType.otDiagram:
var d = (Diagram) rep.GetContextObject();
rep.ShowInProjectView(d);
break;
case ObjectType.otElement:
el = (Element) rep.GetContextObject();
if (el.ClassfierID > 0)
{
el = rep.GetElementByID(el.ClassfierID);
rep.ShowInProjectView(el);
}
else
{
//MiscData(0) PDATA1,PDATA2,
// pdata1 Id for parts, UmlElement
// object_id for text with Hyper link to diagram
// locate text or frame
if (LocateTextOrFrame(rep, el)) return;
string guid = el.MiscData[0];
if (guid.EndsWith("}", StringComparison.Ordinal))
{
el = rep.GetElementByGuid(guid);
rep.ShowInProjectView(el);
}
else
{
if (el.Type.Equals("Action"))
{
foreach (CustomProperty custproperty in el.CustomProperties)
{
if (custproperty.Name.Equals("kind") && custproperty.Value.Contains("AcceptEvent"))
//.........这里部分代码省略.........
示例13: AddElementNote
/// <summary>
/// Add Element note for diagram Object from:<para/>
/// Element, Attribute, Operation, Package
///
/// </summary>
/// <param name="rep"></param>
/// <param name="diaObj"></param>
public static void AddElementNote(Repository rep, DiagramObject diaObj)
{
Element el = rep.GetElementByID(diaObj.ElementID);
if (el != null)
{
Diagram dia = rep.GetCurrentDiagram();
Package pkg = rep.GetPackageByID(el.PackageID);
if (pkg.IsProtected || dia.IsLocked || el.Locked) return;
// save diagram;//
rep.SaveDiagram(dia.DiagramID);
Element elNote;
try
{
elNote = (Element) pkg.Elements.AddNew("", "Note");
elNote.Update();
pkg.Update();
}
catch
{
return;
}
// add element to diagram
// "l=200;r=400;t=200;b=600;"
int left = diaObj.right + 50;
int right = left + 100;
int top = diaObj.top;
int bottom = top - 100;
string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
var diaObject = (DiagramObject) dia.DiagramObjects.AddNew(position, "");
dia.Update();
diaObject.ElementID = elNote.ElementID;
diaObject.Sequence = 1; // put element to top
diaObject.Update();
pkg.Elements.Refresh();
// make a connector
var con = (Connector) el.Connectors.AddNew("test", "NoteLink");
con.SupplierID = elNote.ElementID;
con.Update();
el.Connectors.Refresh();
Util.SetElementHasAttchaedLink(rep, el, elNote);
rep.ReloadDiagram(dia.DiagramID);
}
}
示例14: InsertInterface
// ReSharper disable once UnusedMember.Local
static void InsertInterface(Repository rep, Diagram dia, string text)
{
bool isComponent = false;
Package pkg = rep.GetPackageByID(dia.PackageID);
int pos = 0;
// only one diagram object selected as source
if (dia.SelectedObjects.Count != 1) return;
// save selected object
DiagramObject objSelected = null;
if (!(dia == null && dia.SelectedObjects.Count > 0))
{
objSelected = (DiagramObject) dia.SelectedObjects.GetAt(0);
}
rep.SaveDiagram(dia.DiagramID);
var diaObjSource = (DiagramObject) dia.SelectedObjects.GetAt(0);
var elSource = rep.GetElementByID(diaObjSource.ElementID);
isComponent |= elSource.Type == "Component";
// remember selected object
List<Element> ifList = GetInterfacesFromText(rep, pkg, text);
foreach (Element elTarget in ifList)
{
if (elSource.Locked)
{
MessageBox.Show($"Source '{elSource.Name}' is locked", @"Element locked");
continue;
}
if (isComponent)
{
AddPortToComponent(elSource, elTarget);
}
else
{
AddInterfaceToElement(rep, pos, elSource, elTarget, dia, diaObjSource);
}
pos = pos + 1;
}
// visualize ports
if (isComponent)
{
dia.SelectedObjects.AddNew(diaObjSource.ElementID.ToString(), ObjectType.otElement.ToString());
dia.SelectedObjects.Refresh();
ShowEmbeddedElementsGui(rep);
}
// reload selected object
if (objSelected != null)
{
dia.SelectedObjects.AddNew(elSource.ElementID.ToString(), elSource.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
rep.ReloadDiagram(dia.DiagramID);
dia.SelectedObjects.AddNew(elSource.ElementID.ToString(), elSource.ObjectType.ToString());
dia.SelectedObjects.Refresh();
}
示例15: CreateDiagramObjectFromContext
//----------------------------------------------------------------------------------------
// type: "Action", "Activity","Decision", "MergeNode","StateNode"
// extension: "CallOperation" ,"101"=StateNode, Final, "no"= else/no Merge
// comp=yes: Activity with composite Diagram
//----------------------------------------------------------------------------------------
private static DiagramObject CreateDiagramObjectFromContext(Repository rep, string name, string type,
string extension, int offsetHorizental = 0, int offsetVertical = 0, string guardString = "",
Element srcEl = null)
{
int widthPerCharacter = 60;
// filter out linefeed, tab
name = Regex.Replace(name, @"(\n|\r|\t)", "", RegexOptions.Singleline);
if (name.Length > 255)
{
MessageBox.Show($"{type}: '{name}' has more than 255 characters.", @"Name is to long");
return null;
}
Element elSource;
Element elParent = null;
Element elTarget;
string basicType = type;
if (type == "CallOperation") basicType = "Action";
Diagram dia = rep.GetCurrentDiagram();
if (dia == null) return null;
rep.SaveDiagram(dia.DiagramID);
// only one diagram object selected as source
if (srcEl == null) elSource = Util.GetElementFromContextObject(rep);
else elSource = srcEl;
if (elSource == null) return null;
var diaObjSource = Util.GetDiagramObjectById(rep, dia, elSource.ElementID);
//diaObjSource = dia.GetDiagramObjectByID(elSource.ElementID, "");
string noValifTypes = "Note, Constraint, Boundary, Text, UMLDiagram, DiagramFrame";
if (noValifTypes.Contains(elSource.Type)) return null;
if (elSource.ParentID != 0)
{
Util.GetDiagramObjectById(rep, dia, elSource.ParentID);
//diaObjParent = dia.GetDiagramObjectByID(elSource.ParentID, "");
}
try
{
if (elSource.ParentID > 0)
{
elParent = rep.GetElementByID(elSource.ParentID);
elTarget = (Element) elParent.Elements.AddNew(name, basicType);
if (basicType == "StateNode") elTarget.Subtype = Convert.ToInt32(extension);
elParent.Elements.Refresh();
}
else
{
var pkg = rep.GetPackageByID(elSource.PackageID);
elTarget = (Element) pkg.Elements.AddNew(name, basicType);
if (basicType == "StateNode") elTarget.Subtype = Convert.ToInt32(extension);
pkg.Elements.Refresh();
}
elTarget.ParentID = elSource.ParentID;
elTarget.Update();
if (basicType == "Activity" & extension.ToLower() == "comp=yes")
{
Diagram actDia = ActivityPar.CreateActivityCompositeDiagram(rep, elTarget);
Util.SetActivityCompositeDiagram(rep, elTarget, actDia.DiagramID.ToString());
//elTarget.
}
}
catch
{
return null;
}
int left = diaObjSource.left + offsetHorizental;
int right = diaObjSource.right + offsetHorizental;
int top = diaObjSource.top + offsetVertical;
int bottom = diaObjSource.bottom + offsetVertical;
int length;
if (basicType == "StateNode")
{
left = left - 10 + (right - left)/2;
right = left + 20;
top = bottom - 20;
bottom = top - 20;
}
if ((basicType == "Decision") | (basicType == "MergeNode"))
{
if (guardString == "no")
{
if (elSource.Type == "Decision") left = left + (right - left) + 200;
else left = left + (right - left) + 50;
bottom = bottom - 5;
}
left = left - 15 + (right - left)/2;
right = left + 30;
//.........这里部分代码省略.........