Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2169 ghuddy 1
using System;
2
 
3
namespace EA_ReqPro
4
{
5
	/// <summary>
6
	/// Summary description for EA_Parsing.
7
	/// </summary>
8
	public class EA_Parsing
9
	{
10
		public EA_Parsing()
11
		{
12
		}
13
 
14
      /// <summary>
15
      /// This function is designed to parse EA models/packages in a predefined way, whilst allowing
16
      /// a user to specify what processing is to be done upon or with each element found.
17
      /// The parsing order is based on the order of items in the element collections held by packages.
18
      /// This is fine for work where a client just wants a list of elements and does not care too much
19
      /// about element ordering.
20
      /// </summary>
21
      /// <param name="thePackage"></param>
22
      /// <param name="worker"></param>
23
      /// <param name="recurse"></param>
24
      public static void findAndProcessPackageElements( EA.Package thePackage, EA_RecursionWorker worker, bool recurse)
25
      {
26
         worker.processPackage( thePackage );
27
 
28
         foreach (EA.Element theElement in thePackage.Elements)
29
         {
30
            worker.processElement( theElement );
31
 
32
            if (Main.mustAbort)
33
               return;
34
         }
35
 
36
         if (recurse == true)
37
         {
38
            foreach (EA.Package subPackage in thePackage.Packages)
39
            {
40
               // RECURSION
41
               findAndProcessPackageElements( subPackage, worker, true);
42
 
43
               if (Main.mustAbort)
44
                  return;
45
            }         
46
         }
47
      }
48
 
49
      /// <summary>
50
      /// This function is designed to parse EA models/packages in a predefined way, whilst allowing
51
      /// a user to specify what processing is to be done upon or with each element found.
52
      /// The parsing order is based on the order of items as seen in EA's project browser.
53
      /// </summary>
54
      /// <param name="theElement"></param>
55
      /// <param name="worker"></param>
56
      /// <param name="recurse"></param>
57
      public static void findAndProcessPackageElementsInBrowserOrder( EA.Element theElement, EA_RecursionWorker worker, bool recurse)
58
      {
59
         worker.processElement( theElement );
60
 
61
         if (recurse == true)
62
         {
63
            foreach(EA.Element subElement in theElement.Elements)
64
            {
65
               findAndProcessPackageElementsInBrowserOrder(subElement, worker, recurse);
66
 
67
               if (Main.mustAbort)
68
                  return;
69
            }
70
         }
71
      }
72
 
73
      /// <summary>
74
      /// This function is designed to parse EA models/packages in a predefined way, whilst allowing
75
      /// a user to specify what processing is to be done upon or with each element found.
76
      /// The parsing order is based on the order of items as seen in EA's project browser.
77
      /// </summary>
78
      /// <param name="thePackage"></param>
79
      /// <param name="worker"></param>
80
      /// <param name="recurse"></param>
81
      public static void findAndProcessPackageElementsInBrowserOrder( EA.Package thePackage, EA_RecursionWorker worker, bool recurse)
82
      {
83
         worker.processPackage( thePackage );
84
 
85
         foreach(EA.Element subElement in thePackage.Elements)
86
         {
87
            if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)
88
               findAndProcessPackageElementsInBrowserOrder(subElement, worker, recurse);
89
 
90
            if (Main.mustAbort)
91
               return;
92
         }
93
 
94
         if (recurse == true)
95
         {
96
            foreach(EA.Package lowerLevelPackage in thePackage.Packages)
97
            {
98
               findAndProcessPackageElementsInBrowserOrder(lowerLevelPackage, worker, recurse);
99
 
100
               if (Main.mustAbort)
101
                  return;
102
            }
103
         }
104
      }
105
 
106
	}
107
}