{"id":295242,"date":"2019-11-26T21:00:08","date_gmt":"2019-11-26T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295242"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295242","title":{"rendered":"\u041c\u043e\u043d\u0430\u0434\u0430 \u00abReader\u00bb \u0447\u0435\u0440\u0435\u0437 async\/await \u0432 C#"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/470501\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jb\/8f\/kq\/jb8fkqbv4lkkzgyy4j-66ykf9nu.jpeg\"><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/468017\/\">\u0412 \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f \u043e\u043f\u0438\u0441\u0430\u043b, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d &#171;\u041c\u043e\u043d\u0430\u0434\u0430 Maybe&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <strong>async \/ await<\/strong>. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#171;\u041c\u043e\u043d\u0430\u0434\u0430 Reader&#187;, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435 \u0436\u0435 \u043f\u0440\u0438\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u043b\u0438 \u043f\u043e\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (Dependency Injection). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">class Config { public string Template; }  public static async Task Main() {     Console.WriteLine(await GreetGuys().Apply(new Config {Template = \"Hi, {0}!\"}));     \/\/(Hi, John!, Hi, Jos\u00e9!)      Console.WriteLine(await GreetGuys().Apply(new Config {Template = \"\u00a1Hola, {0}!\" }));     \/\/(\u00a1Hola, John!, \u00a1Hola, Jos\u00e9!) }  \/\/\u0412 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043d\u0435\u0442 \u044f\u0432\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u201cConfig\". public static async Reader&lt;(string gJohn, string gJose)&gt; GreetGuys()      =&gt; (await Greet(\"John\"), await Greet(\"Jos\u00e9\"));  static async Reader&lt;string&gt; Greet(string name)      =&gt; string.Format(await ExtractTemplate(), name);  static async Reader&lt;string&gt; ExtractTemplate()      =&gt; await Reader&lt;string&gt;.Read&lt;Config&gt;(c =&gt; c.Template);<\/code><\/pre>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"klassicheskiy-reader\">\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 &#171;Reader&#187;<\/h2>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0431\u0435\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <strong>async \/ await<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public class Config { public string Template; }  public static class ClassicReader {     public static void Main()     {         var greeter = GreetGuys();          Console.WriteLine(greeter.Apply(new Config{Template = \"Hello, {0}\"}));         \/\/(Hello, John, Hello, Jose)          Console.WriteLine(greeter.Apply(new Config{Template = \"\u00a1Hola, {0}!\" }));         \/\/(\u00a1Hola, John!, \u00a1Hola, Jose!)         }      public static Reader&lt;(string gJohn, string gJose), Config&gt; GreetGuys() =&gt;         from toJohn in Greet(\"John\")         from toJose in Greet(\"Jose\")         select (toJohn, toJose);         \/\/\u0411\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \"query syntax\" \u044d\u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:         \/\/Greet(\"John\")         \/\/    .SelectMany(         \/\/          toJohn =&gt; Greet(\"Jose\"),          \/\/          (toJohn, toJose) =&gt; (toJohn, toJose))      public static Reader&lt;string, Config&gt; Greet(string name)          =&gt; new Reader&lt;string, Config&gt;(cfg =&gt; string.Format(cfg.Template, name)); }<\/code><\/pre>\n<p>  <\/p>\n<p><em>(Reader)<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public class Reader&lt;T, TCtx&gt; {     private readonly Func&lt;TCtx, T&gt; _exec;      public Reader(Func&lt;TCtx, T&gt; exec) =&gt; this._exec = exec;      public T Apply(TCtx ctx) =&gt; this._exec(ctx); }  public static class Reader {     public static Reader&lt;TJoin, TCtx&gt; SelectMany&lt;TIn, TOut, TCtx, TJoin&gt;(         this Reader&lt;TIn, TCtx&gt; source,          Func&lt;TIn, Reader&lt;TOut, TCtx&gt;&gt; bind,          Func&lt;TIn, TOut, TJoin&gt; join)      =&gt;         new Reader&lt;TJoin, TCtx&gt;(ctx =&gt;         {             var inValue = source.Apply(ctx);             var outValue = bind(inValue).Apply(ctx);             return join(inValue, outValue);         }); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u0435\u043d) \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0430\u0434\u0430\u0435\u0442 \u0438 \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043e\u043d\u0430\u0434\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u0433\u0434\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f (\u0445\u043e\u0442\u044f \u0434\u0430\u0436\u0435 \u0432 \u0425\u0430\u0441\u043a\u0435\u043b\u0435\u043b\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 &#171;do&#187; \u043d\u043e\u0442\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c). \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0443\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\"> public static Reader&lt;string, Config&gt; Greet(string name)      =&gt; new Reader&lt;string, Config&gt;(cfg =&gt; string.Format(cfg.Template, name));  \/\/\u0415\u0441\u043b\u0438 \u0431\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430,\u0442\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \/\/public static string Greet(string name, Config cfg)  \/\/    =&gt; string.Format(cfg.Template, name);<\/code><\/pre>\n<p>  <\/p>\n<p><strong>SelectMany<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043e\u0434\u043d\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0446\u0435\u043b\u0443\u044e \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043e \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0435\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435\u043a\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0441\u044f. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 C #, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 (<em> <strong> async \/ await <\/strong> <\/em>), \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u043d\u0430\u0434\u044b &#171;Reader&#187; \u0438\u2026 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043d\u043e! \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443, \u0442\u043e \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e &#171;\u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c&#187; \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0434\u0430\u043d \u0438\u0437\u0432\u043d\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"asinhronnyy-reader\">A\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 &#171;Reader&#187;<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/468017\/\">\u0412 \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 <strong>async\/await<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u044f <strong>\u041e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/strong>. \u0422\u043e\u0442 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0438 \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0442\u0438\u043f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">[AsyncMethodBuilder(typeof(ReaderTaskMethodBuilder&lt;&gt;))] public class Reader&lt;T&gt; : INotifyCompletion, IReader { ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438(\u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430):<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e \u0432\u0441\u0435\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">private readonly Func&lt;object, T&gt; _extractor;  \/\/1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 public static Reader&lt;T&gt; Read&lt;TCtx&gt;(Func&lt;TCtx, T&gt; extractor)      =&gt; new Reader&lt;T&gt;(ctx =&gt; extractor((TCtx)ctx));  private Reader(Func&lt;object, T&gt; exec) =&gt; this._extractor = exec;  \/\/2. \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f ReaderTaskMethodBuilder \u0432 \u043a\u043e\u0434\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c C# internal Reader() { }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <strong>await<\/strong>, \u0442\u043e \u044d\u0442\u043e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u042d\u0442\u043e\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043d\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8q\/k2\/u3\/8qk2u3lwleoo6hfd55fzclhz1sa.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <strong>SetChild<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">private IReader _child;  internal void SetChild(IReader reader) {     this._child = reader;     if (this._ctx != null)     {         this._child.SetCtx(this._ctx);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <strong>ReaderTaskMethodBuilder<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public class ReaderTaskMethodBuilder&lt;T&gt; {     ...     public void GenericAwaitOnCompleted&lt;TAwaiter, TStateMachine&gt;(         ref TAwaiter awaiter,          ref TStateMachine stateMachine)         where TAwaiter : INotifyCompletion         where TStateMachine : IAsyncStateMachine     {         if (awaiter is IReader reader)         {             this.Task.SetChild(reader);         }         awaiter.OnCompleted(stateMachine.MoveNext);     }      public Reader&lt;T&gt; Task { get; } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <strong>SetChild<\/strong> \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>SetCtx<\/strong> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <strong>SetCtx<\/strong> \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f _<strong>extractor<\/strong> (\u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0441\u0441\u0441\u0430 <strong>Reader<\/strong>), \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0447\u0440\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 <strong>SetResult<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public void SetCtx(object ctx) {     this._ctx = ctx;     if (this._ctx != null)     {         this._child?.SetCtx(this._ctx);          if (this._extractor != null)         {             this.SetResult(this._extractor(this._ctx));         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>SetResult<\/strong> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">internal void SetResult(T result) {     this._result = result;     this.IsCompleted = true;     this._continuation?.Invoke(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 _<strong>extractor<\/strong> (\u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Reader<\/strong>), \u0442\u043e\u0433\u0434\u0430 <strong>SetResult<\/strong> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d <strong>ReaderTaskMethodBuilder<\/strong> \u043a\u043e\u0433\u0434\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><strong>SetCtx<\/strong> \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <strong>Apply<\/strong> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u0443\u0437\u043b\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public Reader&lt;T&gt; Apply(object ctx) {     this.SetCtx(ctx);     return this; }<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/0x1000000\/AsyncMonads\/blob\/master\/AsyncMonads\/Reader.cs\">\u041f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0430 GitHub<\/a><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e <strong>Reader<\/strong>-a:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0429\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440.<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">public static class ReaderTest {     public class Configuration     {         public readonly int DataBaseId;          public readonly string GreetingTemplate;          public readonly string NameFormat;          public Configuration(int dataBaseId, string greetingTemplate, string nameFormat)         {             this.DataBaseId = dataBaseId;             this.GreetingTemplate = greetingTemplate;             this.NameFormat = nameFormat;         }     }      public static async Task Main()     {         int[] ids = { 1, 2, 3 };          Configuration[] configurations =         {             new Configuration(100, \"Congratulations, {0}! You won {1}$!\", \"{0} {1}\"),             new Configuration(100, \"\u00a1Felicidades, {0}! Ganaste {1} $\", \"{0}\"),         };          foreach (var configuration in configurations)         {             foreach (var userId in ids)             {                 \/\/\"\u041b\u043e\u0433\u0438\u043a\u0430\" \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044f\u0432\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 - userId                 var logic = GetGreeting(userId);                  \/\/\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (database Id, templates) \u043c\u043e\u0433\u0443 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u043d\u0435\u044f\u0432\u043d\u043e                  var greeting = await logic.Apply(configuration);                  Console.WriteLine(greeting)             }         }         \/\/Congratulations, John Smith! You won 110$!         \/\/Congratulations, Mary Louie! You won 30$!         \/\/Congratulations, Louis Slaughter! You won 47$!         \/\/\u00a1Felicidades, John! Ganaste 110 $         \/\/\u00a1Felicidades, Mary! Ganaste 30 $         \/\/\u00a1Felicidades, Louis! Ganaste 47 $     }      private static async Reader&lt;string&gt; GetGreeting(int userId)     {         var template = await Reader&lt;string&gt;.Read&lt;Configuration&gt;(cfg =&gt; cfg.GreetingTemplate);          var fullName = await GetFullName(userId);          var win = await GetWin(userId);          return string.Format(template, fullName, win);     }      private static async Reader&lt;string&gt; GetFullName(int userId)     {         var template = await Reader&lt;string&gt;.Read&lt;Configuration&gt;(cfg =&gt; cfg.NameFormat);          var firstName = await GetFirstName(userId);         var lastName = await GetLastName(userId);          return string.Format(template, firstName, lastName);     }      private static async Reader&lt;string&gt; GetFirstName(int userId)     {         var dataBase = await GetDataBase();         return await dataBase.GetFirstName(userId);     }      private static async Reader&lt;string&gt; GetLastName(int userId)     {         var dataBase = await GetDataBase();         return await dataBase.GetLastName(userId);     }      private static async Reader&lt;int&gt; GetWin(int userId)     {         var dataBase = await GetDataBase();         return await dataBase.GetWin(userId);     }      private static async Reader&lt;Database&gt; GetDataBase()     {         var dataBaseId = await Reader&lt;int&gt;.Read&lt;Configuration&gt;(cfg =&gt; cfg.DataBaseId);         return Database.ConnectTo(dataBaseId);     } }  public class Database {     public static Database ConnectTo(int id)     {         if (id == 100)         {             return new Database();         }         throw new Exception(\"Wrong database\");     }      private Database() { }      private static readonly (int Id, string FirstName, string LastName, int Win)[] Data =     {         (1, \"John\",\"Smith\", 110),         (2, \"Mary\",\"Louie\", 30),         (3, \"Louis\",\"Slaughter\", 47),     };      public async Task&lt;string&gt; GetFirstName(int id)     {         await Task.Delay(50);         return Data.Single(i =&gt; i.Id == id).FirstName;     }      public async Task&lt;string&gt; GetLastName(int id)     {         await Task.Delay(50);         return Data.Single(i =&gt; i.Id == id).LastName;     }      public async Task&lt;int&gt; GetWin(int id)     {         await Task.Delay(50);         return Data.Single(i =&gt; i.Id == id).Win;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0445 \u0438\u043c\u0435\u043d \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 \u0438\u0437 &#171;, \u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445&#187;. \u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u043e\u0439 &#171;\u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445&#187; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0438 \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u043d\u0430\u043c \u0442\u0430\u043a \u0436\u0435 \u043d\u0443\u0436\u043d\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439. \u0412\u0441\u044f \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u044f\u0432\u043d\u043e, \u0447\u0435\u0440\u0435\u0437 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 <strong>Reader<\/strong>.<\/p>\n<p>  <\/p>\n<h2 id=\"vnedrenie-zavisimostey-chrez-asinhronnyy-reader\">\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0447\u0440\u0435\u0437 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 &#171;Reader&#187;<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 <strong>Reader<\/strong> \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u0438\u043d \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2013 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u042d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 C# \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 (generic type) \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <strong>ReaderTaskMethodBuilder<\/strong> (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445).<\/p>\n<p>  <\/p>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">public static class Reader {     public static Reader&lt;TService&gt; GetService&lt;TService&gt;() =&gt;          Reader&lt;TService&gt;.Read&lt;IServiceProvider&gt;(serviceProvider              =&gt; (TService)serviceProvider                 .GetService(typeof(TService))); }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cs\">... private static async Reader&lt;string&gt; Greet(string userName) {     var service = await Reader.GetService&lt;IGreater&gt;();     return service.GreetUser(userName); } ...<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/0x1000000\/AsyncMonads\/blob\/master\/AsyncMonads.Test\/ReaderServiceProviderTest.cs\">(<em>\u0417\u0434\u0435\u0441\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e&#8230;<\/em>)<\/a><\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/468017\/\">\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u201cMaybe\u201d<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u044f \u0431\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e <strong>Reader<\/strong>-a \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0443 (\u0438\u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435) \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (\u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430) \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 <strong>Reader<\/strong>-a \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043f\u043e\u043b\u044f\u0445, \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0434\u044b \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445.<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <strong>Reader<\/strong>-a \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043b\u043e\u043d\u044f\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0438 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0448\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/li>\n<li>\u041a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c <strong>Reader<\/strong> \u043a\u0430\u043a \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0435\u044f\u0432\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443<\/li>\n<li>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 <strong>Reader<\/strong> \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438 \u0432\u043e\u0437\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u0438\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e <strong>Reader<\/strong>-a, \u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e\u043c \u043b\u044e\u0434\u0435\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f.<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/470501\/\"> https:\/\/habr.com\/ru\/post\/470501\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/470501\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jb\/8f\/kq\/jb8fkqbv4lkkzgyy4j-66ykf9nu.jpeg\"><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/468017\/\">\u0412 \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f \u043e\u043f\u0438\u0441\u0430\u043b, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d &#171;\u041c\u043e\u043d\u0430\u0434\u0430 Maybe&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <strong>async \/ await<\/strong>. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#171;\u041c\u043e\u043d\u0430\u0434\u0430 Reader&#187;, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435 \u0436\u0435 \u043f\u0440\u0438\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u043b\u0438 \u043f\u043e\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (Dependency Injection). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">class Config { public string Template; }  public static async Task Main() {     Console.WriteLine(await GreetGuys().Apply(new Config {Template = \"Hi, {0}!\"}));     \/\/(Hi, John!, Hi, Jos\u00e9!)      Console.WriteLine(await GreetGuys().Apply(new Config {Template = \"\u00a1Hola, {0}!\" }));     \/\/(\u00a1Hola, John!, \u00a1Hola, Jos\u00e9!) }  \/\/\u0412 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043d\u0435\u0442 \u044f\u0432\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u201cConfig\". public static async Reader&lt;(string gJohn, string gJose)&gt; GreetGuys()      =&gt; (await Greet(\"John\"), await Greet(\"Jos\u00e9\"));  static async Reader&lt;string&gt; Greet(string name)      =&gt; string.Format(await ExtractTemplate(), name);  static async Reader&lt;string&gt; ExtractTemplate()      =&gt; await Reader&lt;string&gt;.Read&lt;Config&gt;(c =&gt; c.Template);<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-295242","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295242"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295242\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}