Blame | Last modification | View Log | RSS feed
using System;namespace EA_ReqPro{/// <summary>/// Summary description for EA_Utils./// </summary>public class EA_Utilities{EA.Repository EA_Repository = null;public EA_Utilities(EA.Repository theRepository){EA_Repository = theRepository;}/// <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./// </summary>/// <param name="thePackage"></param>/// <param name="worker"></param>/// <param name="recurse"></param>public void findAndProcessPackageElements( EA.Package thePackage, EA_UtilitiesRecursionWorker worker, bool recurse){worker.processPackage( thePackage );foreach (EA.Element theElement in thePackage.Elements){worker.processElement( theElement );}if (recurse == true){foreach (EA.Package subPackage in thePackage.Packages){// RECURSIONfindAndProcessPackageElements( subPackage, worker, true);}}}public string ReadTag(EA.Element theElement, string tagName){string result;EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);if (null != tag){result = tag.Value;}else{result = "";}return result;}public bool WriteTag(EA.Element theElement, string tagName, string value){bool result;EA.TaggedValue tag;tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);if (null != tag){tag.Value = value;}else{tag = (EA.TaggedValue)theElement.TaggedValues.AddNew(tagName, value);}if (tag != null){result = tag.Update();}else{result = false;}return result;}}/// <summary>/// A Base Class designed to work with the findAndProcessPackageElements method./// Users will normally derive their own classes from this and add real functionality/// to the over-ridable methods the base class provides./// </summary>public class EA_UtilitiesRecursionWorker{public EA_UtilitiesRecursionWorker(){}public virtual void processElement( EA.Element theElement ){}public virtual void processPackage( EA.Package thePackage ){}}}