Пример #1
0
        /// <summary>
        ///     Removes useless prefixes from the string provided
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        protected string StripUseless(string fullName, IModelElement model)
        {
            string retVal = fullName;

            if (model != null)
            {
                string[] words   = fullName.Split('.');
                string[] context = model.FullName.Split('.');

                int i = 0;
                while (i < words.Length && i < context.Length)
                {
                    if (words[i] != context[i])
                    {
                        break;
                    }

                    i++;
                }

                // i is the first different word.
                retVal = "";
                while (i < words.Length)
                {
                    if (!String.IsNullOrEmpty(retVal))
                    {
                        retVal += ".";
                    }
                    retVal = retVal + words[i];
                    i++;
                }

                if (Util.isEmpty(retVal))
                {
                    retVal = model.Name;
                }
            }

            if (retVal.StartsWith(DefaultPrefix))
            {
                retVal = retVal.Substring(DefaultPrefix.Length);
            }

            return(retVal);
        }
Пример #2
0
        /// <summary>
        ///     Updates the node name text according to the modelized item
        /// </summary>
        public virtual void UpdateText()
        {
            string name = "";

            if (DefaultName != null)
            {
                name = DefaultName;
            }
            else
            {
                if (Model != null)
                {
                    name = Model.Name;
                }
            }
            if (Text != name && !Util.isEmpty(name))
            {
                Text = name;
            }
        }
Пример #3
0
 /// <summary>
 ///     Appends a namable in a dictionary of a sub declarator
 /// </summary>
 /// <param name="subDeclarator"></param>
 /// <param name="namable"></param>
 public static void AppendNamable(ISubDeclarator subDeclarator, INamable namable)
 {
     if (namable != null && subDeclarator != null && subDeclarator.DeclaredElements != null)
     {
         if (!Util.isEmpty(namable.Name))
         {
             CriticalSection.WaitOne();
             try
             {
                 if (!subDeclarator.DeclaredElements.ContainsKey(namable.Name))
                 {
                     subDeclarator.DeclaredElements[namable.Name] = new List <INamable>();
                 }
                 subDeclarator.DeclaredElements[namable.Name].Add(namable);
             }
             finally
             {
                 CriticalSection.ReleaseMutex();
             }
         }
     }
 }