关于在 C# 中实现”桥”模式 | 珊瑚贝

Regarding implement of a ‘Bridge’ pattern in C#


我正在尝试在我的应用程序中实现桥接模式,但我遇到了一个我无法解决的问题:
假设我有一个通用的”抽象”类,我想要几个工具,称之为 ImpA


Abstraction 类的重点是在您的情况下从实现 (ImpA) 中抽象出来。这意味着抽象类应该定义客户端应该使用的接口(方法),然后将这些调用传播或”翻译”到实现上的操作。这当然意味着您需要在 Abstraction 类中实现构成公共接口的方法,并让这些方法调用实现。

如果您只想让实际的实现类有所不同,但它们的接口相同并且都暴露给客户端,只需定义一个描述”ImpA”类的公共方法的接口并使用客户端的接口.

您可以在此处找到桥接模式的 .NET 描述:http://www.dofactory.com/Patterns/PatternBridge.aspx#_self1


来源:https://www.codenong.com/7370623/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9532.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?