{"id":96,"date":"2008-03-04T15:31:16","date_gmt":"2008-03-04T15:31:16","guid":{"rendered":""},"modified":"2008-03-04T15:31:16","modified_gmt":"2008-03-04T15:31:16","slug":"96","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=96","title":{"rendered":"\u9002\u914d\u5668\u6a21\u5f0f(Adapter Pattern)"},"content":{"rendered":"<p>\u7ed3\u6784\u6a21\u5f0f\uff08Structural Pattern\uff09\u63cf\u8ff0\u5982\u4f55\u5c06\u7c7b\u6216\u8005\u5bf9\u8c61\u7ed3\u5408\u5728\u4e00\u8d77\u5f62\u6210\u66f4\u5927\u7684\u7ed3\u6784\u3002\u7ed3\u6784\u6a21\u5f0f\u63cf\u8ff0\u4e24\u79cd\u4e0d\u540c\u7684\u4e1c\u897f\uff1a\u7c7b\u4e0e\u7c7b\u7684\u5b9e\u4f8b\u3002\u6839\u636e\u8fd9\u4e00\u70b9\uff0c\u7ed3\u6784\u6a21\u5f0f\u53ef\u4ee5\u5206\u4e3a\u7c7b\u7684\u7ed3\u6784\u6a21\u5f0f\u548c\u5bf9\u8c61\u7684\u7ed3\u6784\u6a21\u5f0f\u3002<\/p>\n<p>\u540e\u7eed\u5185\u5bb9\u5c06\u5305\u62ec\u4ee5\u4e0b\u7ed3\u6784\u6a21\u5f0f\uff1a<\/p>\n<p>\u9002\u914d\u5668\u6a21\u5f0f\uff08Adapter\uff09\uff1aMatch interfaces of different classes <br \/>\u5408\u6210\u6a21\u5f0f\uff08Composite\uff09\uff1aA tree structure of simple and composite objects <br \/>\u88c5\u9970\u6a21\u5f0f\uff08Decorator\uff09\uff1aAdd responsibilities to objects dynamically <br \/>\u4ee3\u7406\u6a21\u5f0f\uff08Proxy\uff09\uff1aAn object representing another object <br \/>\u4eab\u5143\u6a21\u5f0f\uff08Flyweight\uff09\uff1aA fine-grained instance used for efficient sharing <br \/>\u95e8\u9762\u6a21\u5f0f\uff08Facade\uff09\uff1aA single class that represents an entire subsystem <br \/>\u6865\u6881\u6a21\u5f0f\uff08Bridge\uff09\uff1aSeparates an object interface from its implementation <\/p>\n<p>\u4e00\u3001 \u9002\u914d\u5668\uff08Adapter\uff09\u6a21\u5f0f<br \/>\u9002\u914d\u5668\u6a21\u5f0f\u628a\u4e00\u4e2a\u7c7b\u7684\u63a5\u53e3\u53d8\u6362\u6210\u5ba2\u6237\u7aef\u6240\u671f\u5f85\u7684\u53e6\u4e00\u79cd\u63a5\u53e3\uff0c\u4ece\u800c\u4f7f\u539f\u672c\u63a5\u53e3\u4e0d\u5339\u914d\u800c\u65e0\u6cd5\u5728\u4e00\u8d77\u5de5\u4f5c\u7684\u4e24\u4e2a\u7c7b\u80fd\u591f\u5728\u4e00\u8d77\u5de5\u4f5c\u3002<\/p>\n<p>\u540d\u79f0\u7531\u6765<\/p>\n<p>\u8fd9\u5f88\u50cf\u53d8\u538b\u5668\uff08Adapter\uff09\uff0c\u53d8\u538b\u5668\u628a\u4e00\u79cd\u7535\u538b\u53d8\u6362\u6210\u53e6\u4e00\u79cd\u7535\u538b\u3002\u7f8e\u56fd\u7684\u751f\u6d3b\u7528\u7535\u7535\u538b\u662f110V\uff0c\u800c\u4e2d\u56fd\u7684\u7535\u538b\u662f220V\u3002\u5982\u679c\u8981\u5728\u4e2d\u56fd\u4f7f\u7528\u7f8e\u56fd\u7535\u5668\uff0c\u5c31\u5fc5\u987b\u6709\u4e00\u4e2a\u80fd\u628a220V\u7535\u538b\u8f6c\u6362\u6210110V\u7535\u538b\u7684\u53d8\u538b\u5668\u3002\u8fd9\u4e2a\u53d8\u538b\u5668\u5c31\u662f\u4e00\u4e2aAdapter\u3002<\/p>\n<p>Adapter\u6a21\u5f0f\u4e5f\u5f88\u50cf\u8d27\u7269\u7684\u5305\u88c5\u8fc7\u7a0b\uff1a\u88ab\u5305\u88c5\u7684\u8d27\u7269\u7684\u771f\u5b9e\u6837\u5b50\u88ab\u5305\u88c5\u6240\u63a9\u76d6\u548c\u6539\u53d8\uff0c\u56e0\u6b64\u6709\u4eba\u628a\u8fd9\u79cd\u6a21\u5f0f\u53eb\u505a\u5305\u88c5\uff08Wrapper\uff09\u6a21\u5f0f\u3002\u4e8b\u5b9e\u4e0a\uff0c\u5927\u5bb6\u7ecf\u5e38\u5199\u5f88\u591a\u8fd9\u6837\u7684Wrapper\u7c7b\uff0c\u628a\u5df2\u6709\u7684\u4e00\u4e9b\u7c7b\u5305\u88c5\u8d77\u6765\uff0c\u4f7f\u4e4b\u6709\u80fd\u6ee1\u8db3\u9700\u8981\u7684\u63a5\u53e3\u3002<\/p>\n<p>\u9002\u914d\u5668\u6a21\u5f0f\u7684\u4e24\u79cd\u5f62\u5f0f<\/p>\n<p>\u9002\u914d\u5668\u6a21\u5f0f\u6709\u7c7b\u7684\u9002\u914d\u5668\u6a21\u5f0f\u548c\u5bf9\u8c61\u7684\u9002\u914d\u5668\u6a21\u5f0f\u4e24\u79cd\u3002\u6211\u4eec\u5c06\u5206\u522b\u8ba8\u8bba\u8fd9\u4e24\u79cdAdapter\u6a21\u5f0f\u3002<\/p>\n<p>\u4e8c\u3001 \u7c7b\u7684Adapter\u6a21\u5f0f\u7684\u7ed3\u6784\uff1a<br \/><img decoding=\"async\" src=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_0803\/i200834152918.gif\" \/><br \/>\u7531\u56fe\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0cAdaptee\u7c7b\u6ca1\u6709Request\u65b9\u6cd5\uff0c\u800c\u5ba2\u6237\u671f\u5f85\u8fd9\u4e2a\u65b9\u6cd5\u3002\u4e3a\u4e86\u4f7f\u5ba2\u6237\u80fd\u591f\u4f7f\u7528Adaptee\u7c7b\uff0c\u63d0\u4f9b\u4e00\u4e2a\u4e2d\u95f4\u73af\u8282\uff0c\u5373\u7c7bAdapter\u7c7b\uff0cAdapter\u7c7b\u5b9e\u73b0\u4e86Target\u63a5\u53e3\uff0c\u5e76\u7ee7\u627f\u81eaAdaptee\uff0cAdapter\u7c7b\u7684Request\u65b9\u6cd5\u91cd\u65b0\u5c01\u88c5\u4e86Adaptee\u7684SpecificRequest\u65b9\u6cd5\uff0c\u5b9e\u73b0\u4e86\u9002\u914d\u7684\u76ee\u7684\u3002<\/p>\n<p>\u56e0\u4e3aAdapter\u4e0eAdaptee\u662f\u7ee7\u627f\u7684\u5173\u7cfb\uff0c\u6240\u4ee5\u8fd9\u51b3\u5b9a\u4e86\u8fd9\u4e2a\u9002\u914d\u5668\u6a21\u5f0f\u662f\u7c7b\u7684\u3002<\/p>\n<p>\u8be5\u9002\u914d\u5668\u6a21\u5f0f\u6240\u6d89\u53ca\u7684\u89d2\u8272\u5305\u62ec\uff1a<\/p>\n<p>\u76ee\u6807\uff08Target\uff09\u89d2\u8272\uff1a\u8fd9\u662f\u5ba2\u6237\u6240\u671f\u5f85\u7684\u63a5\u53e3\u3002\u56e0\u4e3aC#\u4e0d\u652f\u6301\u591a\u7ee7\u627f\uff0c\u6240\u4ee5Target\u5fc5\u987b\u662f\u63a5\u53e3\uff0c\u4e0d\u53ef\u4ee5\u662f\u7c7b\u3002<br \/>\u6e90\uff08Adaptee\uff09\u89d2\u8272\uff1a\u9700\u8981\u9002\u914d\u7684\u7c7b\u3002<br \/>\u9002\u914d\u5668\uff08Adapter\uff09\u89d2\u8272\uff1a\u628a\u6e90\u63a5\u53e3\u8f6c\u6362\u6210\u76ee\u6807\u63a5\u53e3\u3002\u8fd9\u4e00\u89d2\u8272\u5fc5\u987b\u662f\u7c7b\u3002<\/p>\n<p>\u4e09\u3001 \u7c7b\u7684Adapter\u6a21\u5f0f\u793a\u610f\u6027\u5b9e\u73b0\uff1a<br \/>\u4e0b\u9762\u7684\u7a0b\u5e8f\u7ed9\u51fa\u4e86\u4e00\u4e2a\u7c7b\u7684Adapter\u6a21\u5f0f\u7684\u793a\u610f\u6027\u7684\u5b9e\u73b0\uff1a <br \/><code><br \/>\/\/&nbsp;&nbsp;Class Adapter pattern -- Structural example&nbsp;&nbsp;<br \/>using System;<\/p>\n<p>\/\/ \"ITarget\"<br \/>interface ITarget<br \/>{<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;void Request();<br \/>}<\/p>\n<p>\/\/ \"Adaptee\"<br \/>class Adaptee<br \/>{<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;public void SpecificRequest()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Called SpecificRequest()\" );<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ \"Adapter\"<br \/>class Adapter : Adaptee, ITarget<br \/>{<br \/>&nbsp;&nbsp;\/\/ Implements ITarget interface<br \/>&nbsp;&nbsp;public void Request()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Possibly do some data manipulation<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ and then call SpecificRequest<br \/>&nbsp;&nbsp;&nbsp;&nbsp;this.SpecificRequest();<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/**\/\/\/\/ &lt;summary&gt;<br \/>\/\/\/ Client test<br \/>\/\/\/ &lt;\/summary&gt;<br \/>public class Client<br \/>{<br \/>&nbsp;&nbsp;public static void Main(string[] args)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Create adapter and place a request<br \/>&nbsp;&nbsp;&nbsp;&nbsp;ITarget t = new Adapter();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;t.Request();<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code> <\/p>\n<p>\u56db\u3001 \u5bf9\u8c61\u7684Adapter\u6a21\u5f0f\u7684\u7ed3\u6784\uff1a<br \/><img decoding=\"async\" src=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_0803\/f200834153013.gif\" \/><br \/>\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u51fa\uff1a\u5ba2\u6237\u7aef\u9700\u8981\u8c03\u7528Request\u65b9\u6cd5\uff0c\u800cAdaptee\u6ca1\u6709\u8be5\u65b9\u6cd5\uff0c\u4e3a\u4e86\u4f7f\u5ba2\u6237\u7aef\u80fd\u591f\u4f7f\u7528Adaptee\u7c7b\uff0c\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u5305\u88c5\uff08Wrapper\uff09\u7c7bAdapter\u3002\u8fd9\u4e2a\u5305\u88c5\u7c7b\u5305\u88c5\u4e86\u4e00\u4e2aAdaptee\u7684\u5b9e\u4f8b\uff0c\u4ece\u800c\u5c06\u5ba2\u6237\u7aef\u4e0eAdaptee\u8854\u63a5\u8d77\u6765\u3002\u7531\u4e8eAdapter\u4e0eAdaptee\u662f\u59d4\u6d3e\u5173\u7cfb\uff0c\u8fd9\u51b3\u5b9a\u4e86\u8fd9\u4e2a\u9002\u914d\u5668\u6a21\u5f0f\u662f\u5bf9\u8c61\u7684\u3002<\/p>\n<p>\u8be5\u9002\u914d\u5668\u6a21\u5f0f\u6240\u6d89\u53ca\u7684\u89d2\u8272\u5305\u62ec\uff1a<\/p>\n<p>\u76ee\u6807\uff08Target\uff09\u89d2\u8272\uff1a\u8fd9\u662f\u5ba2\u6237\u6240\u671f\u5f85\u7684\u63a5\u53e3\u3002\u76ee\u6807\u53ef\u4ee5\u662f\u5177\u4f53\u7684\u6216\u62bd\u8c61\u7684\u7c7b\uff0c\u4e5f\u53ef\u4ee5\u662f\u63a5\u53e3\u3002<br \/>\u6e90\uff08Adaptee\uff09\u89d2\u8272\uff1a\u9700\u8981\u9002\u914d\u7684\u7c7b\u3002<br \/>\u9002\u914d\u5668\uff08Adapter\uff09\u89d2\u8272\uff1a\u901a\u8fc7\u5728\u5185\u90e8\u5305\u88c5\uff08Wrap\uff09\u4e00\u4e2aAdaptee\u5bf9\u8c61\uff0c\u628a\u6e90\u63a5\u53e3\u8f6c\u6362\u6210\u76ee\u6807\u63a5\u53e3\u3002<\/p>\n<p>\u4e94\u3001 \u5bf9\u8c61\u7684Adapter\u6a21\u5f0f\u793a\u610f\u6027\u5b9e\u73b0\uff1a<br \/>\u4e0b\u9762\u7684\u7a0b\u5e8f\u7ed9\u51fa\u4e86\u4e00\u4e2a\u7c7b\u7684Adapter\u6a21\u5f0f\u7684\u793a\u610f\u6027\u7684\u5b9e\u73b0\uff1a<br \/><code>\/\/ Adapter pattern -- Structural example&nbsp;&nbsp;<br \/>using System;<\/p>\n<p>\/\/ \"Target\"<br \/>class Target<br \/>{<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;virtual public void Request()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Normal implementation goes here<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ \"Adapter\"<br \/>class Adapter : Target<br \/>{<br \/>&nbsp;&nbsp;\/\/ Fields<br \/>&nbsp;&nbsp;private Adaptee adaptee = new Adaptee();<\/p>\n<p>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;override public void Request()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Possibly do some data manipulation<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ and then call SpecificRequest<br \/>&nbsp;&nbsp;&nbsp;&nbsp;adaptee.SpecificRequest();<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ \"Adaptee\"<br \/>class Adaptee<br \/>{<br \/>&nbsp;&nbsp;\/\/ Methods<br \/>&nbsp;&nbsp;public void SpecificRequest()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Called SpecificRequest()\" );<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/**\/\/\/\/ &lt;summary&gt;<br \/>\/\/\/ Client test<br \/>\/\/\/ &lt;\/summary&gt;<br \/>public class Client<br \/>{<br \/>&nbsp;&nbsp;public static void Main(string[] args)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Create adapter and place a request<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Target t = new Adapter();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;t.Request();<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code><br \/>\u516d\u3001 \u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4f7f\u7528\u9002\u914d\u5668\u6a21\u5f0f<\/p>\n<p>\u5728\u4ee5\u4e0b\u5404\u79cd\u60c5\u51b5\u4e0b\u4f7f\u7528\u9002\u914d\u5668\u6a21\u5f0f\uff1a<\/p>\n<p>1\u3001 \u7cfb\u7edf\u9700\u8981\u4f7f\u7528\u73b0\u6709\u7684\u7c7b\uff0c\u800c\u6b64\u7c7b\u7684\u63a5\u53e3\u4e0d\u7b26\u5408\u7cfb\u7edf\u7684\u9700\u8981\u3002<br \/>2\u3001 \u60f3\u8981\u5efa\u7acb\u4e00\u4e2a\u53ef\u4ee5\u91cd\u590d\u4f7f\u7528\u7684\u7c7b\uff0c\u7528\u4e8e\u4e0e\u4e00\u4e9b\u5f7c\u6b64\u4e4b\u95f4\u6ca1\u6709\u592a\u5927\u5173\u8054\u7684\u4e00\u4e9b\u7c7b\uff0c\u5305\u62ec\u4e00\u4e9b\u53ef\u80fd\u5728\u5c06\u6765\u5f15\u8fdb\u7684\u7c7b\u4e00\u8d77\u5de5\u4f5c\u3002\u8fd9\u4e9b\u6e90\u7c7b\u4e0d\u4e00\u5b9a\u6709\u5f88\u590d\u6742\u7684\u63a5\u53e3\u3002<br \/>3\u3001 \uff08\u5bf9\u5bf9\u8c61\u9002\u914d\u5668\u800c\u8a00\uff09\u5728\u8bbe\u8ba1\u91cc\uff0c\u9700\u8981\u6539\u53d8\u591a\u4e2a\u5df2\u6709\u5b50\u7c7b\u7684\u63a5\u53e3\uff0c\u5982\u679c\u4f7f\u7528\u7c7b\u7684\u9002\u914d\u5668\u6a21\u5f0f\uff0c\u5c31\u8981\u9488\u5bf9\u6bcf\u4e00\u4e2a\u5b50\u7c7b\u505a\u4e00\u4e2a\u9002\u914d\u5668\uff0c\u800c\u8fd9\u4e0d\u592a\u5b9e\u9645\u3002<\/p>\n<p>\u4e03\u3001 \u4e00\u4e2a\u5b9e\u9645\u5e94\u7528Adapter\u6a21\u5f0f\u7684\u4f8b\u5b50<br \/>\u4e0b\u9762\u7684\u7a0b\u5e8f\u6f14\u793a\u4e86Class Adapter\u4e0eObject Adapter\u7684\u5e94\u7528\u3002<br \/><code>\/\/ Example of implementing the Adapter pattern<br \/>using System;<\/p>\n<p>\/\/ Target<br \/>public interface&nbsp;&nbsp;ICar<br \/>{<br \/>&nbsp;&nbsp;void&nbsp;&nbsp;Drive();<br \/>}<\/p>\n<p>\/\/ Direct use without Adapter<br \/>public class&nbsp;&nbsp;CToyota : ICar<br \/>{<br \/>&nbsp;&nbsp;public void&nbsp;&nbsp;Drive()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Vroom Vroom, we're off in our Toyota\");<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ Adaptee<br \/>public class&nbsp;&nbsp;CCessna<br \/>{<br \/>&nbsp;&nbsp;public void&nbsp;&nbsp;Fly()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Static runup OK, we're off in our C172\");<br \/>&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ Class Adapter<br \/>public class&nbsp;&nbsp;CDrivableCessna : CCessna, ICar<br \/>{<br \/>&nbsp;&nbsp;public void&nbsp;&nbsp;Drive()&nbsp;&nbsp;{&nbsp;&nbsp;base.Fly();&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ Object Adapter<br \/>public class&nbsp;&nbsp;CDrivableCessna2 : ICar<br \/>{<br \/>&nbsp;&nbsp;private CCessna&nbsp;&nbsp;m_oContained;<\/p>\n<p>&nbsp;&nbsp;public CDrivableCessna2()<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;m_oContained = new CCessna();<br \/>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;public void&nbsp;&nbsp;Drive()&nbsp;&nbsp;{&nbsp;&nbsp;m_oContained.Fly();&nbsp;&nbsp;}<br \/>}<\/p>\n<p>\/\/ Client<br \/>public class&nbsp;&nbsp;Client<br \/>{<br \/>&nbsp;&nbsp;public static void&nbsp;&nbsp;Main(string[] args)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;ICar&nbsp;&nbsp;oCar = new CToyota();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Console.Write(\"Class Adapter: Driving an Automobile\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oCar.Drive();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oCar = new CDrivableCessna();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.Write(\"Driving a Cessna\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oCar.Drive();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oCar = new CDrivableCessna2();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Console.Write(\" Object Adapter: Driving a Cessna\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oCar.Drive();<br \/>&nbsp;&nbsp;}<br \/>}<br \/><\/code><br \/>\u516b\u3001 \u5173\u4e8eAdapter\u6a21\u5f0f\u7684\u8ba8\u8bba<\/p>\n<p>Adapter\u6a21\u5f0f\u5728\u5b9e\u73b0\u65f6\u6709\u4ee5\u4e0b\u8fd9\u4e9b\u503c\u5f97\u6ce8\u610f\u7684\u5730\u65b9\uff1a<\/p>\n<p>1\u3001 \u76ee\u6807\u63a5\u53e3\u53ef\u4ee5\u7701\u7565\uff0c\u6a21\u5f0f\u53d1\u751f\u9000\u5316\u3002\u4f46\u8fd9\u79cd\u505a\u6cd5\u770b\u4f3c\u5e73\u5eb8\u800c\u5e76\u4e0d\u5e73\u5eb8\uff0c\u5b83\u53ef\u4ee5\u4f7fAdaptee\u4e0d\u5fc5\u5b9e\u73b0\u4e0d\u9700\u8981\u7684\u65b9\u6cd5\uff08\u53ef\u4ee5\u53c2\u8003Default Adapter\u6a21\u5f0f\uff09\u3002\u5176\u8868\u73b0\u5f62\u5f0f\u5c31\u662f\u7236\u7c7b\u5b9e\u73b0\u7f3a\u7701\u65b9\u6cd5\uff0c\u800c\u5b50\u7c7b\u53ea\u9700\u5b9e\u73b0\u81ea\u5df1\u72ec\u7279\u7684\u65b9\u6cd5\u3002\u8fd9\u6709\u4e9b\u50cf\u6a21\u677f\uff08Template\uff09\u6a21\u5f0f\u3002<br \/>2\u3001 \u9002\u914d\u5668\u7c7b\u53ef\u4ee5\u662f\u62bd\u8c61\u7c7b\u3002<br \/>3\u3001 \u5e26\u53c2\u6570\u7684\u9002\u914d\u5668\u6a21\u5f0f\u3002\u4f7f\u7528\u8fd9\u79cd\u529e\u6cd5\uff0c\u9002\u914d\u5668\u7c7b\u53ef\u4ee5\u6839\u636e\u53c2\u6570\u8fd4\u8fd8\u4e00\u4e2a\u5408\u9002\u7684\u5b9e\u4f8b\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed3\u6784\u6a21\u5f0f\uff08Structural Pattern\uff09\u63cf\u8ff0\u5982\u4f55\u5c06\u7c7b\u6216\u8005\u5bf9\u8c61&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-Note"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=96"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}