Blame | Last modification | View Log | RSS feed
using System;namespace EA_ReqPro{/// <summary>/// Summary description for EA_Parsing./// </summary>public class EA_Parsing{public EA_Parsing(){}/// <summary>/// This function is designed to parse EA models/packages in a predefined way, whilst allowing/// a user to specify what processing is to be done upon or with each element found./// The parsing order is based on the order of items in the element collections held by packages./// This is fine for work where a client just wants a list of elements and does not care too much/// about element ordering./// </summary>/// <param name="thePackage"></param>/// <param name="worker"></param>/// <param name="recurse"></param>public static void findAndProcessPackageElements( EA.Package thePackage, EA_RecursionWorker worker, bool recurse){worker.processPackage( thePackage );foreach (EA.Element theElement in thePackage.Elements){worker.processElement( theElement );if (Main.mustAbort)return;}if (recurse == true){foreach (EA.Package subPackage in thePackage.Packages){// RECURSIONfindAndProcessPackageElements( subPackage, worker, true);if (Main.mustAbort)return;}}}/// <summary>/// This function is designed to parse EA models/packages in a predefined way, whilst allowing/// a user to specify what processing is to be done upon or with each element found./// The parsing order is based on the order of items as seen in EA's project browser./// </summary>/// <param name="theElement"></param>/// <param name="worker"></param>/// <param name="recurse"></param>public static void findAndProcessPackageElementsInBrowserOrder( EA.Element theElement, EA_RecursionWorker worker, bool recurse){worker.processElement( theElement );if (recurse == true){foreach(EA.Element subElement in theElement.Elements){findAndProcessPackageElementsInBrowserOrder(subElement, worker, recurse);if (Main.mustAbort)return;}}}/// <summary>/// This function is designed to parse EA models/packages in a predefined way, whilst allowing/// a user to specify what processing is to be done upon or with each element found./// The parsing order is based on the order of items as seen in EA's project browser./// </summary>/// <param name="thePackage"></param>/// <param name="worker"></param>/// <param name="recurse"></param>public static void findAndProcessPackageElementsInBrowserOrder( EA.Package thePackage, EA_RecursionWorker worker, bool recurse){worker.processPackage( thePackage );foreach(EA.Element subElement in thePackage.Elements){if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)findAndProcessPackageElementsInBrowserOrder(subElement, worker, recurse);if (Main.mustAbort)return;}if (recurse == true){foreach(EA.Package lowerLevelPackage in thePackage.Packages){findAndProcessPackageElementsInBrowserOrder(lowerLevelPackage, worker, recurse);if (Main.mustAbort)return;}}}}}