コード例 #1
0
        static void Main(string[] args)
        {
            var visitor = new Visitor {
                Value = "12345"
            };
            var intChild = new IntChild();

            intChild.AcceptVisitor(visitor);

            visitor = new Visitor {
                Value = "1.2345"
            };
            var floatChild = new FloatChild();

            floatChild.AcceptVisitor(visitor);

            visitor = new Visitor {
                Value = "Hello World"
            };
            var stringChild = new StringChild();

            stringChild.AcceptVisitor(visitor);

            Console.WriteLine("intChild.Value    = {0}", intChild.Value);
            Console.WriteLine("floatChild.Value  = {0}", floatChild.Value);
            Console.WriteLine("stringChild.Value = {0}", stringChild.Value);
        }
コード例 #2
0
 public void Visit(StringChild stringChild)
 {
     stringChild.Value = Value.ToString();
 }