示例#1
0
        /// <summary>
        /// Method first tries to find the ProfileElementStereotype object with given fullName isInside the
        /// (static) StereotypeList, and if it doesn't find it, it creates new stereotype objects
        /// and adds it to this list.
        /// <remarks>If the fullStereotypeName is null, method will return null.</remarks>
        /// </summary>
        /// <param fullName="fullStereotypeName">full fullName of stereotype which is being searched</param>
        /// <returns>ProfileElementStereotype object with given fullName founded (or added) in StereotypeList</returns>
        public static ProfileElementStereotype FindOrCreateStereotypeForName(string fullStereotypeName)
        {
            ProfileElementStereotype stereotype = null;

            if (!string.IsNullOrEmpty(fullStereotypeName))
            {
                string shortName = StringManipulationManager.ExtractShortestName(fullStereotypeName, StringManipulationManager.SeparatorSharp);

                foreach (ProfileElementStereotype existingStereotype in Profile.StereotypeList)
                {
                    if (existingStereotype.Name.Equals(fullStereotypeName) || existingStereotype.Name.Equals(shortName))
                    {
                        stereotype = existingStereotype;
                        break;
                    }
                }

                if (stereotype == null)
                {
                    stereotype = new ProfileElementStereotype(Profile.StereotypeList.Count, fullStereotypeName);
                    Profile.StereotypeList.Add(stereotype);
                }
            }
            return(stereotype);
        }
示例#2
0
        /// <summary>
        /// Method creates new instance of ProfileElementStereotype and adds it to ProfileElement's
        /// stereotypes list if it doesn't already exists.
        /// </summary>
        /// <param fullName="fullStereotypeString">the full stereotype fullName</param>
        public void AddStereotype(string fullStereotypeString)
        {
            if (!string.IsNullOrEmpty(fullStereotypeString))
            {
                ProfileElementStereotype stereotype = Profile.FindOrCreateStereotypeForName(fullStereotypeString);

                if (stereotype != null)
                {
                    if (stereotypes == null)
                    {
                        stereotypes = new List <ProfileElementStereotype>();
                    }

                    if (!stereotypes.Contains(stereotype))
                    {
                        stereotypes.Add(stereotype);
                        stereotypes.Sort(CIMComparer.ProfileElementStereotypeComparer);
                    }

                    if (ProfileElementStereotype.StereotypeEnumeration.Equals(stereotype.Name))
                    {
                        isEnumeration = true;
                    }

                    if (ProfileElementStereotype.StereotypeAggregateOf.Equals(stereotype.Name))
                    {
                        isAggregate = true;
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Method checks whether or not given stereotype exist is inside of stereotypes list.
        /// </summary>
        /// <param fullName="stereotype">search for this stereotype</param>
        /// <returns><c>true</c> if stereotype was founded, <c>false</c> otherwise</returns>
        public bool HasStereotype(ProfileElementStereotype stereotype)
        {
            bool hasStereotype = false;

            if (stereotypes != null)
            {
                hasStereotype = stereotypes.Contains(stereotype);
            }
            return(hasStereotype);
        }