Пример #1
0
        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));
        }
Пример #2
0
            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));
            }
Пример #3
0
        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));
        }
Пример #4
0
 public void Accept(IFuncVisitor funcVisitor)
 {
     funcVisitor.Visit(this);
 }