惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 碧海无波

Tomcatsession共享方案--memcached-session-manager No control record for Activity type 1000/4220/1442 in version 000 / 2017 activity planning/qty planning 在html中关于如果function的函数名和input的name一样会发生怎样的现象 媒体类型和字符集 第四章ContentProvider 5.3刷新视图 5.2视图中的Order by 5.1什么是视图 排它锁、意向排它锁 8.3锁定 8.2事务处理 锁和并发的日记 Asp.net Page指令 跨域访问解决方案 angularJS学习之旅(1) MVC框架 GS 未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序解决方案 状态模式
设计模式-桥接模式
碧海无波 · 2014-11-11 · via 博客园 - 碧海无波

关于桥接模式大家都很熟悉,设计模式书上也介绍的非常清楚,但介绍Client调用的不多

客户端调用有多种方式

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 using DesignPattern.Bridge;
 5 
 6 namespace DesignPattern
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             Abstraction a = new RefinedAbstraction(new ConcreteImplementor());
13             a.Operation();
14             
15         }
16     }
17 }

通过构造器注入

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 using DesignPattern.Bridge;
 5 
 6 namespace DesignPattern
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             Abstraction a = new RefinedAbstraction();
13             a.Imp = new ConcreteImplementor();
14             a.Operation();
15             
16         }
17     }
18 }

Set注入

 两种方式都可以实现注入真正的实现类,但是Set方式要稍好些,以后再更换为类似Spring框架注入的时候,非常方便