TSF.UmlToolingFramework.Wrappers.EA.Model.getElementWrapperByGUID C# (CSharp) Method

getElementWrapperByGUID() public method

Finds the EA.Element with the given GUID and returns an EAElementwrapper wrapping this element.
public getElementWrapperByGUID ( string GUID ) : ElementWrapper
GUID string the GUID of the element
return ElementWrapper
        public ElementWrapper getElementWrapperByGUID(string GUID)
        {
            try{
            return this.factory.createElement
              (this.wrappedModel.GetElementByGuid(GUID)) as ElementWrapper;
              } catch( Exception )  {
            // element not found, return null
            return null;
              }
        }

Usage Example

示例#1
0
        public static List <MappingLogic> getMappingLogicsFromString(string logicsString, TSF_EA.Model model)
        {
            var mappingLogics = new List <MappingLogic>();

            if (!string.IsNullOrEmpty(logicsString))
            {
                try
                {
                    XDocument xdoc = XDocument.Load(new System.IO.StringReader(logicsString));
                    foreach (var logicNode in xdoc.Descendants("mappingLogic"))
                    {
                        string contextID = logicNode.Elements("context").FirstOrDefault()?.Value;
                        TSF_EA.ElementWrapper contextElement = model.getElementWrapperByGUID(contextID);
                        string description = logicNode.Elements("description").FirstOrDefault()?.Value;
                        //only create mapping logic if the description exists, or the contextElement exists.
                        if (!string.IsNullOrEmpty(description) || contextElement != null)
                        {
                            mappingLogics.Add(new MappingLogic(description, contextElement));
                        }
                    }
                }
                catch (System.Xml.XmlException)
                {
                    //no xml found, just plain text
                    mappingLogics.Add(new MappingLogic(logicsString));
                }
            }
            return(mappingLogics);
        }