Exemple #1
0
        public static EAAPI.Element Copy(this EAAPI.Element source, EAAPI.Package targetPackage)
        {
            EAAPI.Element targetElement = (EAAPI.Element)targetPackage.Elements.AddNew(source.Name, source.Type);

            targetElement.ClassifierID = source.ClassifierID;
            targetElement.Stereotype   = source.Stereotype;

            if (source.Type == "Part")
            {
                targetElement.PropertyType = source.PropertyType;
            }

            /*
             * if (source.Type == "Action")
             * {
             *  for (int i = 0; i < source.Elements.Count; i++)
             *  {
             *      EA.Element sourceEmbeddedEl = (EA.Element) source.Elements.GetAt((short)i);
             *      EA.Element embeddedEl = (EA.Element) el.Elements.AddNew(sourceEmbeddedEl.Name, sourceEmbeddedEl.Type);
             *      embeddedEl.ClassfierID = sourceEmbeddedEl.ClassfierID;
             *      embeddedEl.Stereotype = sourceEmbeddedEl.Stereotype;
             *
             *      embeddedEl.Update();
             *      el.Elements.Refresh();
             *  }
             * }
             */

            // copy tagged values
            for (short i = 0; i < source.TaggedValues.Count; i++)
            {
                EAAPI.TaggedValue sourceTag = (EAAPI.TaggedValue)source.TaggedValues.GetAt(i);
                EAAPI.TaggedValue targetTag = (EAAPI.TaggedValue)targetElement.TaggedValues.AddNew(sourceTag.Name, sourceTag.Value);
                targetTag.Update();
            }

            targetElement.TaggedValues.Refresh();

            targetElement.Update();


            targetPackage.Elements.Refresh();
            targetPackage.Element.Refresh();

            return(targetElement);
        }
Exemple #2
0
        public static void SetTaggedValueString(this EAAPI.Element modelElement, string tagName, string value, bool isMemo = false)
        {
            for (short cnt = 0; cnt < modelElement.TaggedValues.Count; cnt++)
            {
                EAAPI.TaggedValue tag = modelElement.TaggedValues.GetAt(cnt) as EAAPI.TaggedValue;

                if (tag != null && tag.Name == tagName)
                {
                    if (!isMemo)
                    {
                        tag.Value = value;
                    }
                    else
                    {
                        tag.Value = "<memo>*";
                        tag.Notes = value;
                    }
                    tag.Update();
                    modelElement.TaggedValues.Refresh();
                    return;
                }
            }
            EAAPI.TaggedValue newTag = modelElement.TaggedValues.AddNew(tagName, "") as EAAPI.TaggedValue;
            if (newTag != null)
            {
                if (!isMemo)
                {
                    newTag.Value = value;
                }
                else
                {
                    newTag.Value = "<memo>*";
                    newTag.Notes = value;
                }
                newTag.Update();
            }
            modelElement.TaggedValues.Refresh();
        }
Exemple #3
0
        public static string GetTaggedValueString(this EAAPI.Element modelElement, string tagName)
        {
            string result = "";

            for (short count = 0; count < modelElement.TaggedValues.Count; count++)
            {
                EAAPI.TaggedValue taggedValue = modelElement.TaggedValues.GetAt(count) as EAAPI.TaggedValue;

                if (taggedValue != null && taggedValue.Name == tagName)
                {
                    if (!taggedValue.Value.StartsWith("<memo"))
                    {
                        result = taggedValue.Value;
                    }
                    else
                    {
                        result = taggedValue.Notes;
                    }
                    break;
                }
            }
            return(result);
        }