Factory() public static method

public static Factory ( EA rep, EA objectType, string GUID ) : FindAndReplaceItem
rep EA
objectType EA
GUID string
return FindAndReplaceItem
Esempio n. 1
0
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="pkg"></param>
 /// <param name="fr"></param>
 private static void FindMatchingPackageTaggedValue(EA.Repository rep, EA.Package pkg, FindAndReplace fr)
 {
     EA.Element el = rep.GetElementByGuid(pkg.PackageGUID);
     foreach (EA.TaggedValue tag in el.TaggedValues)
     {
         if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(el, tag.Name));
             if (count > 0)
             {
                 // Create the searchers
                 FindAndReplaceItem frItem = fr.LastItem();
                 if ((frItem == null) || (frItem.Guid != el.ElementGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otPackage, el.ElementGUID);
                     fr.LItems.Add(frItem);
                 }
                 // Search
                 var frItemPkg = (FindAndReplaceItemPackage)frItem;
                 frItemPkg.LItemTag.Add(new FindAndReplaceItemTagPackage(tag));
                 frItemPkg.CountChanges = frItemPkg.CountChanges + count;
             }
         }
     }
 }
        /// <summary>
        /// Find the count of found searches in item:
        /// - add item to l_items
        /// - update item to l_items if item is already available
        ///
        /// </summary>
        /// <param name="object_type"></param>
        /// <param name="GUID"></param>
        public int FindStringInItem(EA.ObjectType object_type, string GUID)
        {
            int count = 0;
            FindAndReplaceItem frItem = null;


            frItem = FindAndReplaceItem.Factory(_rep, object_type, GUID);
            count  = frItem.findCount(_regExPattern, _searchFieldTypes);
            if (count > 0)
            {
                frItem.CountChanges = count;
                this.l_items.Add(frItem);
            }

            return(count);
        }
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="el"></param>
 /// <param name="fr"></param>
 private static void FindMatchingElementTaggedValue(EA.Repository rep, EA.Element el, FindAndReplace fr)
 {
     foreach (EA.TaggedValue tag in el.TaggedValues)
     {
         if ((fr.tagValueNames.Length == 0) || (fr.tagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.findCountForType(fr.regexPattern, tag.Value);
             if (count > 0)
             {
                 FindAndReplaceItem frItem = fr.lastItem();
                 if ((frItem == null) || (frItem.GUID != el.ElementGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otElement, el.ElementGUID);
                     fr.l_items.Add(frItem);
                 }
                 var frItemEl = (FindAndReplaceItemElement)frItem;
                 frItemEl.l_itemTag.Add(new FindAndReplaceItemTagElement(tag));
                 frItemEl.CountChanges = frItemEl.CountChanges + count;
             }
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Find matching tagged values for element
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="method"></param>
        /// <param name="fr"></param>
        private static void FindMatchingMethodTaggedValue(EA.Repository rep, EA.Method method, FindAndReplace fr)
        {
            foreach (EA.MethodTag tag in method.TaggedValues)
            {
                if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
                {
                    int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(method, tag.Name));
                    if (count > 0)
                    {
                        FindAndReplaceItem frItem = fr.LastItem();
                        if ((frItem == null) || (frItem.Guid != method.MethodGUID))
                        {
                            frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otMethod, method.MethodGUID);
                            fr.LItems.Add(frItem);
                        }

                        var frItemMeth = (FindAndReplaceItemMethod)frItem;
                        frItemMeth.LItemTag.Add(new FindAndReplaceItemTagMethod(tag));
                        frItemMeth.CountChanges = frItemMeth.CountChanges + count;
                    }
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="attr"></param>
 /// <param name="fr"></param>
 private static void FindMatchingAttributeTaggedValue(EA.Repository rep, EA.Attribute attr, FindAndReplace fr)
 {
     foreach (EA.AttributeTag tag in attr.TaggedValues)
     {
         if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(attr, tag.Name));
             if (count > 0)
             {
                 FindAndReplaceItem frItem = fr.LastItem();
                 if ((frItem == null) || (frItem.Guid != attr.AttributeGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otAttribute, attr.AttributeGUID);
                     fr.LItems.Add(frItem);
                 }
                 // find tagged value
                 var frItemAttr = (FindAndReplaceItemAttribute)frItem;
                 frItemAttr.LItemTag.Add(new FindAndReplaceItemTagAttribute(tag));
                 frItemAttr.CountChanges = frItemAttr.CountChanges + count;
             }
         }
     }
 }
        /// <summary>
        /// Find matching tagged values for element
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="el"></param>
        /// <param name="fr"></param>
        private static void FindMatchingAttributeTaggedValue(EA.Repository rep, EA.Attribute a, FindAndReplace fr)
        {
            foreach (EA.AttributeTag tag in a.TaggedValues)
            {
                if ((fr.tagValueNames.Length == 0) || (fr.tagValueNames.Contains(tag.Name)))
                {
                    int count = FindAndReplaceItem.findCountForType(fr.regexPattern, tag.Value);
                    if (count > 0)
                    {
                        FindAndReplaceItem frItem = fr.lastItem();
                        if ((frItem == null) || (frItem.GUID != a.AttributeGUID))
                        {
                            frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otAttribute, a.AttributeGUID);
                            fr.l_items.Add(frItem);
                        }

                        var frItemAttr = (FindAndReplaceItemAttribute)frItem;
                        frItemAttr.l_itemTag.Add(new FindAndReplaceItemTagAttribute(tag));
                        frItemAttr.CountChanges = frItemAttr.CountChanges + count;
                    }
                }
            }
        }