开发者

Proxy for a software to increase its functionality

I have a software that communicates with api of a website. How could I increase its functionality to connect to various other api's without touching the code in it? I think the easiest way is to write a proxy that resides between api and softwre translates i开发者_JAVA百科ncoming messages from other api to the base api that this software "understands". Where should I look for more information on implementing this proxy using c#? Thank you for help.


Hmm sounds like one of the Software design patterns you come across every day. I think what fits best with your "proxy" is actually bridge.

From 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.

The example in C# is http://sourcemaking.com/design_patterns/bridge/c%2523

However if you just want the proxy design pattern (which imho doesn't suit your problem) is listed here:

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

EDIT: Ok, for a more generalised solution, go with Proxy pattern and look at existing implementations for proxies. You'll find quite a few answers to that answer question on this site:

  • How to write a proxy in C#?
  • How to create a simple proxy in C#?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜