Skip to content

Instantly share code, notes, and snippets.

@kosanmil
Last active February 2, 2019 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosanmil/028ee471b8ff9c477ca8d4e0d37cdf83 to your computer and use it in GitHub Desktop.
Save kosanmil/028ee471b8ff9c477ca8d4e0d37cdf83 to your computer and use it in GitHub Desktop.
public class FindEmptyProcessUnitsVisitor : IVisitor
{
//Return value list
public List<ProcessUnit> EmptyProcessUnits { get; private set; }
public FindEmptyProcessUnitsVisitor()
{
EmptyProcessUnits = new List<ProcessUnit>();
}
public void VisitProcessUnit(ProcessUnit unit)
{
if (unit.ChildUnits.Count() > 0)
{
foreach (var childUnit in unit.ChildUnits)
childUnit.AcceptVisitor(this);
}
else
{
//Add the process unit to the return value list
EmptyProcessUnits.Add(unit);
}
}
public void VisitAgentUnit(AgentUnit unit)
{
//Is not a process unit, ignored.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment