Book a Demo

Author Topic: get fully qualified name of element  (Read 4945 times)

Maggie

  • EA User
  • **
  • Posts: 106
  • Karma: +0/-0
    • View Profile
get fully qualified name of element
« on: May 03, 2013, 08:48:06 pm »
Hi
In an addin I can get the name of an EA.Element.
However, I want to get the fully qualified name i.e. one that includes the namespace.
e.g. class xyz lives in namespace abc so I want something that returns abc::xyz

Is this possible

Maggie

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: get fully qualified name of element
« Reply #1 on: May 03, 2013, 08:54:05 pm »
Traverse the parent package back to one that is a namespace root and concatenate the names.

q.

Maggie

  • EA User
  • **
  • Posts: 106
  • Karma: +0/-0
    • View Profile
Re: get fully qualified name of element
« Reply #2 on: May 03, 2013, 08:55:09 pm »
Thanks qwerty

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: get fully qualified name of element
« Reply #3 on: May 06, 2013, 04:52:27 pm »
I implementd that in my EA Add-in Framework:

The code for Element looks like this:
Code: [Select]
     public string fqn
      {
            get
            {
                  string nodepath = string.Empty;
                  if (this.owner != null)
                  {
                        nodepath = this.owner.fqn;
                  }
                  if (this.name.Length > 0)
                  {
                        if (nodepath.Length > 0)
                        {
                              nodepath = nodepath + ".";
                        }
                        nodepath = nodepath + this.name;
                  }                  
                  return nodepath;
            }
      }

Geert

Maggie

  • EA User
  • **
  • Posts: 106
  • Karma: +0/-0
    • View Profile
Re: get fully qualified name of element
« Reply #4 on: May 07, 2013, 05:54:50 pm »
Thanks Geert  :)