码迷,mamicode.com
首页 > 其他好文 > 详细

设计模式学习笔记--适配器模式

时间:2016-05-28 23:13:17      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1 using System;
 2 
 3 namespace Adapter
 4 {
 5     /// <summary> 
 6     /// 作者:bzyzhang
 7     /// 时间:2016/5/28 20:47:51 
 8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
 9     /// Target说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
10     /// </summary> 
11     public class Target
12     {
13         public virtual void Request()
14         {
15             Console.WriteLine("普通请求!");
16         }
17     }
18 }
View Code
技术分享
 1 using System;
 2 
 3 namespace Adapter
 4 {
 5     /// <summary> 
 6     /// 作者:bzyzhang
 7     /// 时间:2016/5/28 20:48:50 
 8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
 9     /// Adaptee说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
10     /// </summary> 
11     public class Adaptee
12     {
13         public void SpecialRequest()
14         {
15             Console.WriteLine("特殊请求!");
16         }
17     }
18 }
View Code
技术分享
 1 using System;
 2 
 3 namespace Adapter
 4 {
 5     /// <summary> 
 6     /// 作者:bzyzhang
 7     /// 时间:2016/5/28 20:49:48 
 8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
 9     /// Adapter说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
10     /// </summary> 
11     public class Adapter:Target
12     {
13         private Adaptee adaptee = new Adaptee();
14 
15         public override void Request()
16         {
17             adaptee.SpecialRequest();
18         }
19     }
20 }
View Code
技术分享
 1 namespace Adapter
 2 {
 3     class Program
 4     {
 5         static void Main(string[] args)
 6         {
 7             Target target = new Adapter();
 8             target.Request();
 9         }
10     }
11 }
View Code

 

设计模式学习笔记--适配器模式

标签:

原文地址:http://www.cnblogs.com/bzyzhang/p/5538393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!