TSF.UmlToolingFramework.Wrappers.EA.Model.getItemFromGUID C# (CSharp) Méthode

getItemFromGUID() public méthode

finds the item with the given guid
public getItemFromGUID ( string guidString ) : TSF.UmlToolingFramework.UML.Extended.UMLItem
guidString string the string with the guid
Résultat TSF.UmlToolingFramework.UML.Extended.UMLItem
        public UML.Extended.UMLItem getItemFromGUID(string guidString)
        {
            try
              		{
              			if (guidString.Contains("_"))
            {
              				guidString = this.wrappedModel.GetProjectInterface().XMLtoGUID(guidString);
            }
              		UML.Extended.UMLItem foundItem = null;
              		foundItem = this.getElementByGUID(guidString);
              		if (foundItem == null) foundItem = this.getDiagramByGUID(guidString);
              		if (foundItem == null) foundItem = this.getAttributeWrapperByGUID(guidString);
              		if (foundItem == null) foundItem = this.getOperationByGUID(guidString);
              		if (foundItem == null) foundItem = this.getRelationByGUID(guidString);
              		return foundItem;
              		}
              		catch (System.Runtime.InteropServices.COMException e)
              		{
              			if (e.Message.Contains("Can't find matching ID"))
              			{
              				return null;
              			}
              			else
              			{
              				throw e;
              			}
              		}
        }

Usage Example

        /// <summary>
        /// called when the selected item changes
        /// This operation will show the guid of the selected element in the eaControl
        /// </summary>
        /// <param name="Repository">the EA.Repository</param>
        /// <param name="GUID">the guid of the selected item</param>
        /// <param name="ot">the object type of the selected item</param>
        public override void EA_OnContextItemChanged(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            if (this.eaControl == null)
            {
                this.eaControl = Repository.AddWindow("My Control", "MyAddin.MyEAControl") as MyEAControl;
            }
            if (this.eaControl != null)
            {
                var    model  = new TSF_EA.Model(Repository);
                var    action = model.getItemFromGUID(GUID) as TSF_EA.Action;
                string name   = GUID;
//				if( action != null)
//				{
//					action.kind = TSF_EA.ActionKind.BroadcastSignal;
//					action.save();
//
//					name = action.name +" "+ Enum.GetName(typeof(TSF_EA.ActionKind), action.kind);
//				}
                this.eaControl.setNameLabel(name);
            }
        }