【问题标题】:Proxy for a software to increase its functionality软件的代理以增加其功能
【发布时间】:2011-06-30 18:37:25
【问题描述】:

我有一个与网站的 api 通信的软件。我怎样才能增加它的功能以连接到各种其他 api 而无需触及其中的代码?我认为最简单的方法是编写一个位于 api 和软件之间的代理,将来自其他 api 的传入消息转换为该软件“理解”的基本 api。 我应该在哪里查找有关使用 c# 实现此代理的更多信息? 谢谢你的帮助。

【问题讨论】:

    标签: c# proxy tcp


    【解决方案1】:

    嗯,听起来像是您每天都会遇到的软件设计模式之一。我认为最适合您的“代理”的实际上是桥接器。

    来自sourcemaking

    Intent
    
    - Decouple an abstraction from its implementation so that the two can vary independently.
    - Publish interface in an inheritance hierarchy, and bury implementation in its own inheritance hierarchy.
    - Beyond encapsulation, to insulation
    
    Problem
    
    “Hardening of the software arteries” has occurred by using subclassing of an abstract base class
     to provide alternative implementations. This locks in compile-time binding between interface 
     and implementation. The abstraction and implementation cannot be independently extended or composed.
    

    C#中的例子是http://sourcemaking.com/design_patterns/bridge/c%2523

    但是,如果您只想在此处列出代理设计模式(恕我直言不适合您的问题):

    1. Proxy Pattern.
    2. Proxy Pattern in C#.

    编辑:好的,对于更通用的解决方案,使用代理模式并查看代理的现有实现。你会在这个网站上找到很多关于这个答案问题的答案:

    【讨论】:

    • 您好,感谢您的回复。我认为更多的是在本地机器上运行的真正代理服务器来接收来自软件的通信(我没有过多提及,但它又老又复杂,是什么使得更新非常耗时)并将这些消息转换为其他 api 并连接与其他 api。我发现了这个:codeproject.com/KB/IP/mywebserver.aspx,并认为这可能是该服务器的基础......我的推理是否正确?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 2023-03-28
    • 2020-06-16
    • 2011-06-22
    • 1970-01-01
    • 2012-04-19
    • 2012-08-20
    相关资源
    最近更新 更多