{"id":463337,"date":"2025-06-13T21:00:08","date_gmt":"2025-06-13T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463337"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463337","title":{"rendered":"<span>C#, \u041a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 DDD \u0427\u0430\u0441\u0442\u044c 3.1 \u2014 \u041f\u0440\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Nuget. \u0423\u0431\u0438\u0440\u0430\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e. \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 MVC<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f82\/030\/84e\/f8203084eeaf1f5b0779c7739e8adafe.jpg\" width=\"1024\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f82\/030\/84e\/f8203084eeaf1f5b0779c7739e8adafe.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f82\/030\/84e\/f8203084eeaf1f5b0779c7739e8adafe.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042d\u0442\u043e &#8212; \u0442\u0440\u0435\u0442\u044c\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 \u0441\u0435\u0440\u0438\u0438 DDD \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f. (<a href=\"https:\/\/habr.com\/ru\/articles\/906778\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u0430\u044f <\/a>\u0447\u0430\u0441\u0442\u044c).\u00a0\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0434 MVC \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<h2>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 nuget \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h2>\n<p>\u0414\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0434\u0430\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55a\/e4b\/e18\/55ae4be18ef5f5a26f56891468c45117.png\" alt=\"\u0424\u0430\u0439\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0443 partial \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439\\\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0444\u0430\u0439\u043b\u0435 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c.\" title=\"\u0424\u0430\u0439\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0443 partial \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439\\\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0444\u0430\u0439\u043b\u0435 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c.\" width=\"505\" height=\"334\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/55a\/e4b\/e18\/55ae4be18ef5f5a26f56891468c45117.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55a\/e4b\/e18\/55ae4be18ef5f5a26f56891468c45117.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0424\u0430\u0439\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0443 partial \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439\\\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0444\u0430\u0439\u043b\u0435 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 nuget \u043f\u0430\u043a\u0435\u0442\u043e\u0432. <strong>\u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 cookbook, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c nuget \u0432 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a<\/strong>:<\/p>\n<pre><code class=\"xml\">&lt;ItemGroup&gt; &lt;PackageReference Include=\"Microsoft.CodeAnalysis.CSharp\" Version=\"3.9.0\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;PackageReference Include=\"Microsoft.CodeAnalysis.Analyzers\" Version=\"3.0.0\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;PackageReference Include=\"Microsoft.Extensions.DependencyInjection\" Version=\"9.0.5\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt;  &lt;PackageReference Include=\"Newtonsoft.Json\" Version=\"12.0.1\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;None Include=\"$(OutputPath)\\$(AssemblyName).dll\" Pack=\"true\" PackagePath=\"analyzers\/dotnet\/cs\" Visible=\"false\" \/&gt;  &lt;None Include=\"$(PkgNewtonsoft_Json)\\lib\\netstandard2.0\\*.dll\" Pack=\"true\" PackagePath=\"analyzers\/dotnet\/cs\" Visible=\"false\" \/&gt; &lt;\/ItemGroup&gt;  &lt;PropertyGroup&gt; &lt;GetTargetPathDependsOn&gt;$(GetTargetPathDependsOn);GetDependencyTargetPaths&lt;\/GetTargetPathDependsOn&gt; &lt;\/PropertyGroup&gt;  &lt;Target Name=\"GetDependencyTargetPaths\"&gt; &lt;ItemGroup&gt; &lt;!-- &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PKGCsvTextFieldParser)\\lib\\netstandard2.0\\CsvTextFieldParser.dll\" IncludeRuntimeDependency=\"false\" \/&gt; &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PKGHandlebars_Net)\\lib\\netstandard2.0\\Handlebars.dll\" IncludeRuntimeDependency=\"false\" \/&gt;--&gt; &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PkgNewtonsoft_Json)\\lib\\netstandard2.0\\*.dll\" IncludeRuntimeDependency=\"false\" \/&gt; &lt;\/ItemGroup&gt; &lt;\/Target&gt;<\/code><\/pre>\n<p>\u0411\u0435\u0437 GetTargetPathDependsOn <strong>\u0444\u0430\u0439\u043b\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 VisualStudio<\/strong>, \u043d\u043e <strong>\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442<\/strong> (\u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442).<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a:<\/p>\n<pre><code class=\"cs\">using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces;  namespace Domain.Entities.RequestEntities.MachineOne.Alert {     [WebApiMethod(Endpoint = \"\/MachineOne\/alert\", Methods = WebApiMethodRequestTypes.Post)]     internal class MachineOneRequestAlert : IWebApiWithBulkInsert     {         [WebApiMethodParameterFromBody()]         public AlertBodyObject alert { get; set; }     } } <\/code><\/pre>\n<pre><code class=\"cs\">using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces;  namespace Domain.Entities.RequestEntities.MachineOne.State {     [WebApiMethod(Endpoint = \"\/MachineOne\/state\", Methods = WebApiMethodRequestTypes.Get)]     internal class MachineOneRequestState : IWebApiWithBulkInsert     {         [WebApiMethodParameterFromUri(ParameterName = \"stateObject\")]         public StateUriObject state { get; set; }     } } <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a WebApi, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 \u0432 \u0448\u0438\u043d\u0443. C IP \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0434\u0430\u0442\u043e\u0439.<\/p>\n<pre><code class=\"cs\">using Microsoft.AspNetCore.Mvc;  using Domain.Common.Interfaces.Infrastructure.MessageBus;  using Domain.Entities.RequestEntities.MachineOne.State; using Domain.Entities.RequestEntities.MachineOne.Alert;  namespace Infrastructure.Web.Controllers {     \/\/[ApiController]     public partial class GeneratedWebController : ControllerBase     {                  [HttpGet(\"\/MachineOne\/state\")]         public IActionResult GetMachineOneRequestState([FromServices] ILogger logger,[FromServices] IMessageBus busService, [FromQuery]StateUriObject stateObject)         {             try             {                                  GeneratedMachineOneRequestStateRequestObject request = new GeneratedMachineOneRequestStateRequestObject()                 {                     stateObject = stateObject,                      SourceIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(),                     Date = DateTime.Now                 };                                            busService.Send(request, MessageBus.WebApiBulk).Wait();             }             catch (Exception ex)             {                 logger.LogError(ex, \"WebAPIWithBulkInsert\", Request);             }                         return Ok();         }          [HttpPost(\"\/MachineOne\/alert\")]         public IActionResult GetMachineOneRequestAlert([FromServices] ILogger logger,[FromServices] IMessageBus busService, [FromBody]AlertBodyObject alert)         {             try             {                                  GeneratedMachineOneRequestAlertRequestObject request = new GeneratedMachineOneRequestAlertRequestObject()                 {                     alert = alert,                      SourceIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(),                     Date = DateTime.Now                 };                                            busService.Send(request, MessageBus.WebApiBulk).Wait();             }             catch (Exception ex)             {                 logger.LogError(ex, \"WebAPIWithBulkInsert\", Request);             }                         return Ok();         }      } } <\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. \u042d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u044b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432 \u0448\u0438\u043d\u0443, \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0448\u0438\u043d\u044b \u0438 \u043b\u043e\u0436\u0435\u043c \u0432 \u0411\u0414.<\/p>\n<pre><code class=\"cs\">using System;  using Domain.Entities.RequestEntities.MachineOne.State; using Domain.Entities.RequestEntities.MachineOne.Alert;  namespace Infrastructure.Web.Controllers {          public class GeneratedMachineOneRequestStateRequestObject     {                                public StateUriObject stateObject {get;set;}               public DateTime Date {get;set;}          public string SourceIp {get;set;}     }       public class GeneratedMachineOneRequestAlertRequestObject     {                  public AlertBodyObject alert {get;set;}                             public DateTime Date {get;set;}          public string SourceIp {get;set;}     }   } <\/code><\/pre>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f <\/h2>\n<p>\u0418\u0437 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c:<\/p>\n<p>1) <strong>\u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432\u0441\u0435 \u0432 1 \u043c\u0435\u0442\u043e\u0434\u0435<\/strong> &#8212; \u0434\u0430, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0443 \u0421\u0442\u0438\u0432\u0430 \u041c\u0430\u043a\u043a\u043e\u043d\u043d\u0435\u043b\u043b\u0430. \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0439\u0442\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435.<\/p>\n<p>2) <strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438<\/strong> &#8212; \u0434\u0430, \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u0438\u043b\u0435 <\/p>\n<pre><code class=\"cs\">@$\" using Microsoft.AspNetCore.Mvc;  using Domain.Common.Interfaces.Infrastructure.MessageBus; {GenerateUsings(data)}  namespace Infrastructure.Web.Controllers {{     \/\/[ApiController]     public partial class GeneratedWebController : ControllerBase     {{         {GenerateMethods(data)}     }} }} \"<\/code><\/pre>\n<p>\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b.<\/p>\n<p>3) <strong>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 Generated <\/strong>&#8212; \u0434\u0430, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0433\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u0441\u044e\u0434\u0443, \u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <strong>public <\/strong>DTO, \u0438 \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e. \u0414\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 <strong>Internal <\/strong>\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0436\u0435 \u043c\u043d\u043e\u0433\u043e. \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0443 \u043a\u0443\u0447\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 Generated.<\/p>\n<p>4) <strong>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430<\/strong> &#8212; \u044d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u0430\u043a-\u043b\u0438\u0431\u043e \u0438\u043d\u0430\u0447\u0435. \u0418 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 &#8212; \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0432 500 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c namespace \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u0442\u0435\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0418 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0441\u043a\u0430\u043d\u0435\u0440\u0430:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">using CodeGen.GeneratorBase; using CodeGen.GeneratorBase.Context; using CodeGen.GeneratorBase.FileManager; using CodeGen.Utils.Scan; using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces; using System.Collections.Generic; using System.Linq;  namespace CodeGen.Generators.WebApiWithBulkInsert {     internal class RequestEntityScanner : ICodeGeneratorScanner&lt;RequestEntityGeneratorDTO&gt;     {         public RequestEntityScanner()         {         }          public GeneratedFileInfo GetDescription(RequestEntityGeneratorDTO data)         {             throw new System.NotImplementedException();         }          public List&lt;RequestEntityGeneratorDTO&gt; Scan(GenerationContext projectContext)         {             var result = new List&lt;RequestEntityGeneratorDTO&gt;();              \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c IRequestEntity             var items = projectContext.GetAllClassesWithInterface&lt;IWebApiWithBulkInsert&gt;();              foreach (var item in items)             {                 \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c Endpoint-\u0430 \u0438 Http \u043c\u0435\u0442\u043e\u0434\u0430                 WebApiMethodAttribute requestAttr = item.GetAttribute&lt;WebApiMethodAttribute&gt;();                  \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435                 var uriParamsRaw = item.Properties.Where(i=&gt;i.GetAttribute&lt;WebApiMethodParameterFromUriAttribute&gt;()!=null).ToList();                 var bodyParamsRaw = item.Properties.Where(i =&gt; i.GetAttribute&lt;WebApiMethodParameterFromBody&gt;() != null).ToList();                                   \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0432 DTO                 result.Add(new RequestEntityGeneratorDTO()                 {                     defaultPath = requestAttr.Endpoint,                     methods = requestAttr?.Methods ?? WebApiMethodRequestTypes.Get,                      \/\/requestEntityType = item,                     bodyParam = bodyParamsRaw.Select(i =&gt; new RequestEntityParam()                     {                         Name = i.Name,                         UriNameParameter = i.Name,                         Parameter = i.Type                     })                     .ToList(),                      uriParameters = uriParamsRaw.Select(i =&gt; new RequestEntityParam()                     {                         Name = i.Name,                         UriNameParameter = i.GetAttribute&lt;WebApiMethodParameterFromUriAttribute&gt;().ParameterName,                         Parameter = i.Type                     })                     .ToList(),                      requestEntityType = item                 });             }              return result;         }     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 WebApi:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">using CodeGen.GeneratorBase; using CodeGen.GeneratorBase.Context; using CodeGen.Utils.Scan; using CodeGeneration.GeneratorBase; using Domain.Common.Generation.WebApiMethod.Attributes; using System.Collections.Generic;  namespace CodeGen.Generators.WebApiWithBulkInsert.Infrastructure.Web {     class RequestEntityWebGenerator : CodeGeneratorBase&lt;RequestEntityGeneratorDTO&gt;     {         private ICodeGeneratorScanner&lt;RequestEntityGeneratorDTO&gt; scanner;         public RequestEntityWebGenerator()          {             place = GeneratorRunPlace.InfrastructureWeb;             scanner = new RequestEntityScanner();         }                  public override void Generate(GenerationContext context, List&lt;RequestEntityGeneratorDTO&gt; data)         {             \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0448\u0430\u043f\u043a\u0443             string txtExample = $@\" using Microsoft.AspNetCore.Mvc;  using Domain.Common.Interfaces.Infrastructure.MessageBus; {GenerateUsings(data)}  namespace Infrastructure.Web.Controllers {{     \/\/[ApiController]     public partial class GeneratedWebController : ControllerBase     {{         {GenerateMethods(data)}     }} }} \";              context.AddSource(\"Generated_WebApiWithBulkInsert_WebControllers\", txtExample);         }          \/\/\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b WebAPI         private string GenerateMethods(List&lt;RequestEntityGeneratorDTO&gt; data)         {             var txtExample = \"\";              foreach (var item in data)             {                 txtExample += GenerateMethod(item)+\"\\r\\n\";             }              return txtExample;         }          \/\/\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 WebApi         private string GenerateMethod(RequestEntityGeneratorDTO item)         {             var txtExample = \"\";              \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043a \u043c\u0435\u0442\u043e\u0434\u0443             if (item.methods == WebApiMethodRequestTypes.Get)                 txtExample += $@\"         [HttpGet(\"\"{item.defaultPath}\"\")]\";             else if (item.methods == WebApiMethodRequestTypes.Post)                 txtExample += $@\"         [HttpPost(\"\"{item.defaultPath}\"\")]\";              \/\/\u0414\u0435\u043b\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434             txtExample += $@\"         public IActionResult Get{item.requestEntityType.Name}([FromServices] ILogger logger,[FromServices] IMessageBus busService, {GenerateParameters(item)})         {{             try             {{                 {GenerateBody(item)}                  busService.Send(request, MessageBus.WebApiBulk).Wait();             }}             catch (Exception ex)             {{                 logger.LogError(ex, \"\"WebAPiWithBulkInsert\"\", Request);             }}                         return Ok();         }}\";              return txtExample;         }          \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c using-\u0438         private string GenerateUsings(List&lt;RequestEntityGeneratorDTO&gt; data)         {             var txtExample = \"\";             foreach (var item in data)             {                 foreach (var uri in item.uriParameters)                     txtExample += $\"\\r\\nusing {uri.Parameter.Namespace};\";                  foreach (var body in item.bodyParam)                     txtExample += $\"\\r\\nusing {body.Parameter.Namespace};\";              }                          return txtExample;         }          \/\/\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430         private object GenerateBody(RequestEntityGeneratorDTO data)         {             return $@\"                 Generated{data.requestEntityType.Name}RequestObject request = new Generated{data.requestEntityType.Name}RequestObject()                 {{                     {GenerateAssigns(data)}                     SourceIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(),                     Date = DateTime.Now                 }};                          \";         }          \/\/\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435         private string GenerateAssigns(RequestEntityGeneratorDTO data)         {             string result = \"\";              foreach (var item in data.uriParameters)             {                 result += $\"{item.UriNameParameter} = {item.UriNameParameter},\\r\\n\";             }              foreach (var item in data.bodyParam)             {                 result += $\"{item.UriNameParameter} = {item.UriNameParameter},\\r\\n\";             }              return result;         }          \/\/\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432         private object GenerateParameters(RequestEntityGeneratorDTO data)         {             var result = \"\";             foreach(var item in data.uriParameters)             {                 result += \"[FromQuery]\";                 result += item.Parameter.Name;                 result += \" \" + item.UriNameParameter + \", \";             }              foreach (var item in data.bodyParam)             {                 result += \"[FromBody]\";                 result += item.Parameter.Name;                 result += \" \" + item.UriNameParameter + \", \";             }              return result.Substring(0, result.Length - 2);         }          public override List&lt;RequestEntityGeneratorDTO&gt; Parse(GenerationContext projectContext)         {             return scanner.Scan(projectContext);         }     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0418 \u043a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 DTO \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">using CodeGen.GeneratorBase; using CodeGen.GeneratorBase.Context; using CodeGen.Utils.Scan; using CodeGeneration.GeneratorBase; using System.Collections.Generic;  namespace CodeGen.Generators.WebApiWithBulkInsert.Application.Common {     class RequestEntityObjectWebGenerator : CodeGeneratorBase&lt;RequestEntityGeneratorDTO&gt;     {         private ICodeGeneratorScanner&lt;RequestEntityGeneratorDTO&gt; scanner;         public RequestEntityObjectWebGenerator()          {             place = GeneratorRunPlace.ApplicationCommon;             scanner = new RequestEntityScanner();         }                  public override void Generate(GenerationContext context, List&lt;RequestEntityGeneratorDTO&gt; data)         {             \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0448\u0430\u043f\u043a\u0443             string txtExample = $@\" using System; {GenerateUsings(data)}  namespace Infrastructure.Web.Controllers {{     {GenerateClasses(data)} }} \";              context.AddSource(\"Generated_WebApiWithBulkInsert_RequestDTOs\", txtExample);         }          private string GenerateClasses(List&lt;RequestEntityGeneratorDTO&gt; data)         {             var txtExample = \"\";              foreach (var item in data)             {                 txtExample += GenerateClass(item)+\"\\r\\n\";             }              return txtExample;         }          private string GenerateClass(RequestEntityGeneratorDTO item)         {             var txtExample = $@\"     public class Generated{item.requestEntityType.Name}RequestObject     {{         {GenerateProperties(item)}              {GenerateFields(item)}              public DateTime Date {{get;set;}}          public string SourceIp {{get;set;}}     }} \";             return txtExample;         }          private object GenerateFields(RequestEntityGeneratorDTO data)         {             var result = \"\";              foreach (var item in data.uriParameters)             {                 result += @\"         public \";                 result += item.Parameter.Name;                 result += \" \" + item.UriNameParameter + \" {get;set;}\\r\\n\";             }              return result;         }          private object GenerateProperties(RequestEntityGeneratorDTO data)         {             var result = \"\";              foreach (var item in data.bodyParam)             {                 result += @\"         public \";                 result += item.Parameter.Name;                 result += \" \" + item.UriNameParameter + \" {get;set;}\\r\\n\";             }              return result;         }          private string GenerateUsings(List&lt;RequestEntityGeneratorDTO&gt; data)         {             var txtExample = \"\";             foreach (var item in data)             {                 foreach (var uri in item.uriParameters)                     txtExample += $\"\\r\\nusing {uri.Parameter.Namespace};\";                  foreach (var body in item.bodyParam)                     txtExample += $\"\\r\\nusing {body.Parameter.Namespace};\";              }                          return txtExample;         }          public override List&lt;RequestEntityGeneratorDTO&gt; Parse(GenerationContext projectContext)         {             return scanner.Scan(projectContext);         }     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0427\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0435<\/h2>\n<p>\u041a\u043e\u0434 DTO \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432 Application (\u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0448\u0438\u043d\u044b) \u0432\u044b\u043d\u0435\u0441\u0435\u043d \u0432 Application.Common.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0448\u0438\u043d\u0430\u043c\u0438 (\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 Infrastructure.MessageBus).<\/p>\n<h2>\u0410 \u0447\u0442\u043e \u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439?<\/h2>\n<p>\u041f\u043e \u0441\u043e\u0432\u0435\u0442\u0443<a class=\"mention\" href=\"\/users\/onets\">@onets<\/a>(<a href=\"https:\/\/habr.com\/ru\/articles\/542300\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/articles\/542300\/<\/a>) \u0443\u0431\u0440\u0430\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0430\u0445 (\u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438) \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 Namespace \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0414\u0430\u0436\u0435 \u0442\u0435\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 public. \u041e\u0431\u0435\u0440\u0442\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u0438\u043f\u0430\u0445 \u043e\u0441\u0442\u0430\u0432\u0438\u043b, \u0442.\u043a. \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0438 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u0435\u0439.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0436\u0435 <a class=\"mention\" href=\"\/users\/IvanG\">@IvanG<\/a>\u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u0435\u043d. (\u0418, \u0434\u0430, \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e Solution \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435).<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u0431\u043e\u0440\u043a\u0430\u043c\u0438 \u0443\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. (\u0421\u043c. \u0447\u0430\u0441\u0442\u044c 2 &#8212; \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u0418 \u0443\u0431\u0440\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430)<\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041d\u0430\u0448\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0438\u0445 \u0432\u0438\u0434\u043d\u043e \u0432 Swagger<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee4\/f00\/fc3\/ee4f00fc3ace0011f090c1dd0fc93a06.png\" alt=\"Swagger\" title=\"Swagger\" width=\"1546\" height=\"306\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ee4\/f00\/fc3\/ee4f00fc3ace0011f090c1dd0fc93a06.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee4\/f00\/fc3\/ee4f00fc3ace0011f090c1dd0fc93a06.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>Swagger<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c Api \u0435\u0449\u0435 \u043d\u0435\u043b\u044c\u0437\u044f &#8212; \u043c\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0448\u0438\u043d\u0430\u043c\u0438 \u0438 Worker-\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0430\u0434\u0430\u0442\u044c \u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 <strong>\u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u0430 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f CRUD<\/strong> \u043f\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0432 \u0411\u0414. \u0418 \u0434\u0430\u0436\u0435 \u0431\u0430\u0437\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f CRUD \u0447\u0435\u0440\u0435\u0437 CQRS :).<\/p>\n<p>\u0414\u0430\u0436\u0435 <strong>\u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u0435\u0449\u0435 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d, \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 10 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u0447\u0435\u043c \u043f\u0438\u0448\u0435\u0442\u0441\u044f<\/strong> (20 \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0442\u043e\u0447\u0435\u043a WebApi \u043f\u0440\u043e\u0442\u0438\u0432 200 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435\\DTO).<\/p>\n<p><a href=\"https:\/\/github.com\/ValeriyAndreevichPushkarev\/IOT\/blob\/main\/SuperIOT(part31).rar\" rel=\"noopener noreferrer nofollow\"><strong>\u0424\u0430\u0439\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0442\u0443\u0442<\/strong><\/a><\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0448\u0438\u043d\u0430\u043c\u0438 \u0438 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438 (\u0438 \u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435).<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/articles\/918236\/\"> https:\/\/habr.com\/ru\/articles\/918236\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e &#8212; \u0442\u0440\u0435\u0442\u044c\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 \u0441\u0435\u0440\u0438\u0438 DDD \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f. (<a href=\"https:\/\/habr.com\/ru\/articles\/906778\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u0430\u044f <\/a>\u0447\u0430\u0441\u0442\u044c).\u00a0\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0434 MVC \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<h2>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 nuget \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h2>\n<p>\u0414\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0434\u0430\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"\">\n<div><figcaption>\u0424\u0430\u0439\u043b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0443 partial \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439\\\u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0444\u0430\u0439\u043b\u0435 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 nuget \u043f\u0430\u043a\u0435\u0442\u043e\u0432. <strong>\u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 cookbook, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c nuget \u0432 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a<\/strong>:<\/p>\n<pre><code class=\"xml\">&lt;ItemGroup&gt; &lt;PackageReference Include=\"Microsoft.CodeAnalysis.CSharp\" Version=\"3.9.0\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;PackageReference Include=\"Microsoft.CodeAnalysis.Analyzers\" Version=\"3.0.0\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;PackageReference Include=\"Microsoft.Extensions.DependencyInjection\" Version=\"9.0.5\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt;  &lt;PackageReference Include=\"Newtonsoft.Json\" Version=\"12.0.1\" PrivateAssets=\"all\" GeneratePathProperty=\"true\" \/&gt; &lt;None Include=\"$(OutputPath)\\$(AssemblyName).dll\" Pack=\"true\" PackagePath=\"analyzers\/dotnet\/cs\" Visible=\"false\" \/&gt;  &lt;None Include=\"$(PkgNewtonsoft_Json)\\lib\\netstandard2.0\\*.dll\" Pack=\"true\" PackagePath=\"analyzers\/dotnet\/cs\" Visible=\"false\" \/&gt; &lt;\/ItemGroup&gt;  &lt;PropertyGroup&gt; &lt;GetTargetPathDependsOn&gt;$(GetTargetPathDependsOn);GetDependencyTargetPaths&lt;\/GetTargetPathDependsOn&gt; &lt;\/PropertyGroup&gt;  &lt;Target Name=\"GetDependencyTargetPaths\"&gt; &lt;ItemGroup&gt; &lt;!-- &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PKGCsvTextFieldParser)\\lib\\netstandard2.0\\CsvTextFieldParser.dll\" IncludeRuntimeDependency=\"false\" \/&gt; &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PKGHandlebars_Net)\\lib\\netstandard2.0\\Handlebars.dll\" IncludeRuntimeDependency=\"false\" \/&gt;--&gt; &lt;TargetPathWithTargetPlatformMoniker Include=\"$(PkgNewtonsoft_Json)\\lib\\netstandard2.0\\*.dll\" IncludeRuntimeDependency=\"false\" \/&gt; &lt;\/ItemGroup&gt; &lt;\/Target&gt;<\/code><\/pre>\n<p>\u0411\u0435\u0437 GetTargetPathDependsOn <strong>\u0444\u0430\u0439\u043b\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 VisualStudio<\/strong>, \u043d\u043e <strong>\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442<\/strong> (\u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442).<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a:<\/p>\n<pre><code class=\"cs\">using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces;  namespace Domain.Entities.RequestEntities.MachineOne.Alert {     [WebApiMethod(Endpoint = \"\/MachineOne\/alert\", Methods = WebApiMethodRequestTypes.Post)]     internal class MachineOneRequestAlert : IWebApiWithBulkInsert     {         [WebApiMethodParameterFromBody()]         public AlertBodyObject alert { get; set; }     } } <\/code><\/pre>\n<pre><code class=\"cs\">using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces;  namespace Domain.Entities.RequestEntities.MachineOne.State {     [WebApiMethod(Endpoint = \"\/MachineOne\/state\", Methods = WebApiMethodRequestTypes.Get)]     internal class MachineOneRequestState : IWebApiWithBulkInsert     {         [WebApiMethodParameterFromUri(ParameterName = \"stateObject\")]         public StateUriObject state { get; set; }     } } <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a WebApi, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 \u0432 \u0448\u0438\u043d\u0443. C IP \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0434\u0430\u0442\u043e\u0439.<\/p>\n<pre><code class=\"cs\">using Microsoft.AspNetCore.Mvc;  using Domain.Common.Interfaces.Infrastructure.MessageBus;  using Domain.Entities.RequestEntities.MachineOne.State; using Domain.Entities.RequestEntities.MachineOne.Alert;  namespace Infrastructure.Web.Controllers {     \/\/[ApiController]     public partial class GeneratedWebController : ControllerBase     {                  [HttpGet(\"\/MachineOne\/state\")]         public IActionResult GetMachineOneRequestState([FromServices] ILogger logger,[FromServices] IMessageBus busService, [FromQuery]StateUriObject stateObject)         {             try             {                                  GeneratedMachineOneRequestStateRequestObject request = new GeneratedMachineOneRequestStateRequestObject()                 {                     stateObject = stateObject,                      SourceIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(),                     Date = DateTime.Now                 };                                            busService.Send(request, MessageBus.WebApiBulk).Wait();             }             catch (Exception ex)             {                 logger.LogError(ex, \"WebAPIWithBulkInsert\", Request);             }                         return Ok();         }          [HttpPost(\"\/MachineOne\/alert\")]         public IActionResult GetMachineOneRequestAlert([FromServices] ILogger logger,[FromServices] IMessageBus busService, [FromBody]AlertBodyObject alert)         {             try             {                                  GeneratedMachineOneRequestAlertRequestObject request = new GeneratedMachineOneRequestAlertRequestObject()                 {                     alert = alert,                      SourceIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(),                     Date = DateTime.Now                 };                                            busService.Send(request, MessageBus.WebApiBulk).Wait();             }             catch (Exception ex)             {                 logger.LogError(ex, \"WebAPIWithBulkInsert\", Request);             }                         return Ok();         }      } } <\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. \u042d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u044b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432 \u0448\u0438\u043d\u0443, \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0448\u0438\u043d\u044b \u0438 \u043b\u043e\u0436\u0435\u043c \u0432 \u0411\u0414.<\/p>\n<pre><code class=\"cs\">using System;  using Domain.Entities.RequestEntities.MachineOne.State; using Domain.Entities.RequestEntities.MachineOne.Alert;  namespace Infrastructure.Web.Controllers {          public class GeneratedMachineOneRequestStateRequestObject     {                                public StateUriObject stateObject {get;set;}               public DateTime Date {get;set;}          public string SourceIp {get;set;}     }       public class GeneratedMachineOneRequestAlertRequestObject     {                  public AlertBodyObject alert {get;set;}                             public DateTime Date {get;set;}          public string SourceIp {get;set;}     }   } <\/code><\/pre>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f <\/h2>\n<p>\u0418\u0437 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c:<\/p>\n<p>1) <strong>\u041d\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432\u0441\u0435 \u0432 1 \u043c\u0435\u0442\u043e\u0434\u0435<\/strong> &#8212; \u0434\u0430, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0443 \u0421\u0442\u0438\u0432\u0430 \u041c\u0430\u043a\u043a\u043e\u043d\u043d\u0435\u043b\u043b\u0430. \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0439\u0442\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435.<\/p>\n<p>2) <strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438<\/strong> &#8212; \u0434\u0430, \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u0438\u043b\u0435 <\/p>\n<pre><code class=\"cs\">@$\" using Microsoft.AspNetCore.Mvc;  using Domain.Common.Interfaces.Infrastructure.MessageBus; {GenerateUsings(data)}  namespace Infrastructure.Web.Controllers {{     \/\/[ApiController]     public partial class GeneratedWebController : ControllerBase     {{         {GenerateMethods(data)}     }} }} \"<\/code><\/pre>\n<p>\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b.<\/p>\n<p>3) <strong>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 Generated <\/strong>&#8212; \u0434\u0430, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0433\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u0441\u044e\u0434\u0443, \u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <strong>public <\/strong>DTO, \u0438 \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e. \u0414\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 <strong>Internal <\/strong>\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0436\u0435 \u043c\u043d\u043e\u0433\u043e. \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0443 \u043a\u0443\u0447\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 Generated.<\/p>\n<p>4) <strong>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430<\/strong> &#8212; \u044d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043a\u0430\u043a-\u043b\u0438\u0431\u043e \u0438\u043d\u0430\u0447\u0435. \u0418 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 &#8212; \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0432 500 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c namespace \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u0442\u0435\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0418 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0441\u043a\u0430\u043d\u0435\u0440\u0430:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">using CodeGen.GeneratorBase; using CodeGen.GeneratorBase.Context; using CodeGen.GeneratorBase.FileManager; using CodeGen.Utils.Scan; using Domain.Common.Generation.WebApiMethod.Attributes; using Domain.Common.Generation.WebApiWithBulkInsert.Interfaces; using System.Collections.Generic; using System.Linq;  namespace CodeGen.Generators.WebApiWithBulkInsert {     internal class RequestEntityScanner : ICodeGeneratorScanner&lt;RequestEntityGeneratorDTO&gt;     {         public RequestEntityScanner()         {         }          public GeneratedFileInfo GetDescription(RequestEntityGeneratorDTO data)         {             throw new System.NotImplementedException();         }          public List&lt;RequestEntityGeneratorDTO&gt; Scan(GenerationContext projectContext)         {             var result = new List&lt;RequestEntityGeneratorDTO&gt;();              \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c IRequestEntity             var items = projectContext.GetAllClassesWithInterface&lt;IWebApiWithBulkInsert&gt;();              foreach (var item in items)             {                 \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c Endpoint-\u0430 \u0438 Http \u043c\u0435\u0442\u043e\u0434\u0430                 WebApiMethodAttribute requestAttr = item.GetAttribute&lt;WebApiMethodAttribute&gt;();                  \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435                 var uriParamsRaw = item.Properties.Where(i=&gt;i.GetAttribute&lt;WebApiMethodParameterFromUriAttribute&gt;()!=null).ToList();                 var bodyParamsRaw = item.Properties.Where(i =&gt; i.GetAttribute&lt;WebApiMethodParameterFromBody&gt;() != null).ToList();                                   \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0432 DTO                 result.Add(new RequestEntityGeneratorDTO()                 {                     defaultPath = requestAttr.Endpoint,                     methods = requestAttr?.Methods ?? WebApiMethodRequestTypes.Get,                      \/\/requestEntityType = item,                     bodyParam = bodyParamsRaw.Select(i =&gt; new RequestEntityParam()                     {                         Name = i.Name,                         UriNameParameter = i.Name,                         Parameter = i.Type                     })                     .ToList(),                      uriParameters = uriParamsRaw.Select(i =&gt; new RequestEntityParam()                     {                         Name = i.Name,                         UriNameParameter = i.GetAttribute&lt;WebApiMethodParameterFromUriAttribute&gt;().ParameterName,                         Parameter = i.Type                     })                     .ToList(),                      requestEntityType = item                 <\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-463337","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463337","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=463337"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463337\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}