Skip to content

Instantly share code, notes, and snippets.

kosanmil

Block or report user

Report or block kosanmil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HandymanVisitorExample.cs
using System.Collections.Generic;
public class House
{
public List<Room> Rooms;
public void AcceptVisitor(IVisitor visitor)
{
//The handyman will perform checks on this house
//(e.g. check the outside walls)
View StartUnitVisitorExample.cs
var visitor = new StartUnitVisitor();
processUnitToStart.AcceptVisitor(visitor);
Console.WriteLine("Process unit {0} started", processUnitToStart);
View StartUnitVisitor.cs
public class StartUnitVisitor : IVisitor
{
public void VisitProcessUnit(ProcessUnit unit)
{
foreach (var childUnit in unit.ChildUnits)
childUnit.AcceptVisitor(this);
}
public void VisitAgentUnit(AgentUnit unit)
{
@kosanmil
kosanmil / Unit.cs
Last active Feb 2, 2019
Snippet containing implementation of Unit, ProcessUnit and AgentUnit
View Unit.cs
public abstract class Unit
{
public string Name;
public State State;
public abstract void AcceptVisitor(IVisitor visitor);
}
public class ProcessUnit : Unit
{
View IVisitor.cs
public interface IVisitor
{
void VisitProcessUnit(ProcessUnit unit);
void VisitAgentUnit(AgentUnit unit);
}
You can’t perform that action at this time.