您的位置:首页 > 其它

Visitor 表示一个作用于某个对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作

2007-01-17 13:41 591 查看
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6
using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Gof.Test.Visitor
6
ObjectStructure os = new ObjectStructure();
2 os.Attach(new ConcereteElementA());
3 os.Attach(new ConcereteElementB());
4
5 //create visitor objects
6 ConcereteVisitor1 v1 = new ConcereteVisitor1();
7 ConcereteVisitor2 v2 = new ConcereteVisitor2();
8
9 //accepting visitors
10 os.Accept(v1);
11 os.Accept(v2);
12
13 Console.ReadKey();

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐