private static void FuncVisitor() { Console.WriteLine("Func Visitor"); IFuncVisitor <Letter, string> visitor = Visitor.For <Letter, string>(); visitor.Register <A>(x => x.GetType().Name); visitor.Register <B>(x => x.GetType().Name); Letter a = new A(); Letter b = new B(); Console.WriteLine(visitor.Visit(a)); Console.WriteLine(visitor.Visit(b)); }
public void Do() { Console.WriteLine("Func Visitor"); IFuncVisitor <Letter, string> visitor = Visitor.For <Letter, string>(); visitor.Register <A>(ProcessA); visitor.Register <B>(ProcessB); Letter a = new A(); Letter b = new B(); Console.WriteLine(visitor.Visit(a)); Console.WriteLine(visitor.Visit(b)); }
public void FuncVisitor_Visit_Success() { var mock = new Mock <VisitorTests>(); IFuncVisitor <Letter, int> visitor = Visitor.For <Letter, int>(); visitor.Register <A>(mock.Object.VisitFunc); var value = new A(); visitor.Visit(value); mock.Verify(x => x.VisitFunc(value)); }
public void Accept(IFuncVisitor funcVisitor) { funcVisitor.Visit(this); }