{"id":293471,"date":"2019-08-16T15:00:26","date_gmt":"2019-08-16T15:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293471"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293471","title":{"rendered":"\u0421\u0432\u043e\u0439 mapper \u0438\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e ExpressionTrees"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ry\/x_\/sj\/ryx_sj0phsfsrlfz1tcxy2_8izs.jpeg\" alt=\"image\"\/><\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 <a href=\"https:\/\/automapper.org\/\">AutoMapper<\/a>. \u0414\u0430, \u043c\u043d\u0435 \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e\u0431 \u044d\u0442\u043e\u043c, \u043d\u043e \u044f \u043d\u0435 \u0441\u043c\u043e\u0433\u0443. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u0438\u043c\u0435\u044e\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0431 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0439 \u043f\u0443\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u042f \u043b\u0438\u0448\u044c \u043c\u043e\u0433\u0443 \u0434\u0430\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0434\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0430\u043c\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u00ab\u043c\u0430\u043f\u043f\u0435\u0440\u043e\u0432\u00bb. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  \u042f \u0435\u0449\u0451 \u0440\u0430\u0437 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e: \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 mapper. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0432\u0434\u0440\u0443\u0433 \u0432\u0437\u0434\u0443\u043c\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0434\u0435 \u2014 \u043d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u044d\u0442\u043e\u0433\u043e. \u0412\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0435\u0442 \u0441\u0442\u0435\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u044d\u0442\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438 <i>\u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442<\/i> \u0438\u0445 \u0440\u0435\u0448\u0430\u0442\u044c. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c\u0438 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e-mapper \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u044d\u0442\u043e: <\/p>\n<ul>\n<li>\u041d\u0443\u0436\u043d\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f.<\/li>\n<li>\u041d\u0443\u0436\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0432\u0430\u0448\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0438 \u0432\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043d\u0430\u0431\u0438\u0432\u0430\u0442\u044c \u0448\u0438\u0448\u043a\u0438.<\/li>\n<li>\u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 mapper.<\/li>\n<li>\u0412\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u0435\u043b\u043e\u0441\u043f\u043e\u0440\u0442.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0427\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u043e\u0432\u043e\u043c \u00abmapper\u00bb?<\/h3>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0437\u044f\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c (\u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0439. \u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430: \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c DTO \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0438\u0437\u043d\u0435\u0441 \u0441\u043b\u043e\u044f. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 mapper \u00ab\u0431\u0435\u0436\u0438\u0442\u00bb \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c (property) \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0413\u0434\u0435-\u0442\u043e \u043f\u043e \u043f\u0443\u0442\u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f mapper \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"cs\">public interface IMapper&lt;out TOut&gt; {      TOut Map(object source); } <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u044e: \u044d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0443\u0434\u043e\u0431\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043c\u0430\u043f\u043f\u0435\u0440\u043e\u043c (IMapper&lt;TIn, TOut&gt;) \u0438\u043b\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u043c \u0444\u0430\u0441\u0430\u0434\u043e\u043c (IMapper), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c \u043f\u043e\u0434\u0431\u0435\u0440\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 mapper \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u0430-\u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<h3>\u041d\u0430\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>  \u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0434\u0430\u0436\u0435 \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f mapper&#8217;a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/csharp\/programming-guide\/concepts\/reflection\">Reflection<\/a> \u0438 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/csharp\/programming-guide\/concepts\/expression-trees\/\">ExpressionTrees<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043e\u0431 \u044d\u0442\u0438\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u0445 \u2014 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u044d\u0442\u043e, \u043f\u0440\u043e\u0447\u0442\u0438\u0442\u0435. \u041e\u0431\u0435\u0449\u0430\u044e, \u043c\u0438\u0440 \u0443\u0436\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<p>  \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 mapper. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/api\/system.reflection.propertyinfo?view=netcore-2.0\">PropertyInfo<\/a>) \u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 (\u0434\u0430\u043b\u0435\u0435 \u044f \u0431\u0443\u0434\u0443 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e <b>TOut<\/b>). \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0442\u0438\u043f \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0438\u0448\u0435\u043c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e generic-\u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u043e\u043c TOut. \u0414\u0430\u043b\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 Type, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<pre><code class=\"cs\">Type outType = typeof(TOut); PropertyInfo[] outProperties = outType.GetProperties(); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u044f \u043e\u043f\u0443\u0441\u043a\u0430\u044e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0437 setter-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u043a\u0430\u043a \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<p>  \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u0435\u0435. \u0411\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0443\u043c\u0435\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 TOut, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u00ab\u043c\u0430\u043f\u0438\u043c\u00bb \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0412 C# \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a: System.Activator.CreateInstance(). \u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e new TOut(), \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f TOut, \u0447\u0435\u0433\u043e \u0432 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0447\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u043c \u043e\u0431 ExpressionTrees, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">ConstructorInfo outConstructor = outType.GetConstructor(Array.Empty&lt;Type&gt;()); Func&lt;TOut&gt; activator = outConstructor == null    ? throw new Exception($&quot;Default constructor for {outType.Name} not found&quot;)    : Expression.Lambda&lt;Func&lt;TOut&gt;&gt;(Expression.New(outConstructor)).Compile(); <\/code><\/pre>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 Type \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u2014 \u044d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0435\u0448\u0438\u043c \u0440\u0430\u0437\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 mapper \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0430\u043a\u0436\u0435, \u043c\u044b \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0437\u043d\u0430\u043b\u0438 \u043f\u0440\u043e ExpressionTrees, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043b\u0435\u0442\u0443 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a () =&gt; new TOut().<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 mapper&#8217;a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438: \u0438\u0434\u0451\u043c \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u043d\u0430\u043c \u043d\u0430 \u0432\u0445\u043e\u0434, \u0438 \u0438\u0449\u0435\u043c \u0441\u0440\u0435\u0434\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c. \u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u2014 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<pre><code class=\"cs\">TOut outInstance = _activator(); PropertyInfo[] sourceProperties = source.GetType().GetProperties();  for (var i = 0; i &lt; sourceProperties.Length; i++) {      PropertyInfo sourceProperty = sourceProperties[i];      string propertyName = sourceProperty.Name;      if (_outProperties.TryGetValue(propertyName, out PropertyInfo outProperty))      {           object sourceValue = sourceProperty.GetValue(source);           outProperty.SetValue(outInstance, sourceValue);      } }  return outInstance; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/teoadal\/veloimplementations\/blob\/master\/src\/Velo\/Mapping\/BasicMapper.cs\">BasicMapper<\/a>. \u0421 \u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/teoadal\/veloimplementations\/blob\/master\/src\/Velo.Tests\/MappingTests.cs\">\u0432\u043e\u0442 \u0442\u0443\u0442<\/a>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0442\u0430\u043a \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 boxing<\/h3>\n<p>  <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/csharp\/programming-guide\/concepts\/reflection\">Reflection<\/a> \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f, \u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0435\u0451 \u0447\u0430\u0441\u0442\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 memory traffic, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 GC, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/api\/system.reflection.propertyinfo.setvalue?view=netcore-2.0\">PropertyInfo.SetValue<\/a> \u0438 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/api\/system.reflection.propertyinfo.getvalue?view=netcore-2.0\">PropertyInfo.GetValue<\/a>. \u041c\u0435\u0442\u043e\u0434 GetValue \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 object, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u043e (boxing) \u043d\u0435\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u044e \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>  Mapper&#8217;\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439\u2026 \u041d\u0435\u0442, \u043d\u0435 \u043e\u0434\u0438\u043d, \u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>  \u0427\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u041d\u0430\u043c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/csharp\/programming-guide\/concepts\/expression-trees\/\">ExpressionTrees<\/a>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e .NET \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u00ab\u043d\u0430 \u043b\u0435\u0442\u0443\u00bb: \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0447\u0442\u043e \u0438 \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u2026 \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c. \u041f\u043e\u0447\u0442\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438.<\/p>\n<h3>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 mapper<\/h3>\n<p>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043c\u044b \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 new \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Expression.New(ConstructorInfo). \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 New \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0443 \u0432\u0441\u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 C# \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 Expression. \u0415\u0441\u043b\u0438 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435\u0442, \u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u0438\u0449\u0438\u0442\u0435 \u0442.\u043d. \u00ab\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440\u00bb.<\/p>\n<p>  \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c mapper&#8217;e:<\/p>\n<ul>\n<li>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u2014 Expression.Variable(Type, string). \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 Type \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430, \u0430 string \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/li>\n<li>\u041f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u2014 Expression.Assign(Expression, Expression). \u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u044d\u0442\u043e \u0442\u043e, \u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u2014 \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c.<\/li>\n<li>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2014 Expression.Property(Expression, PropertyInfo). Expression \u2014 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 PropertyInfo \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 Reflection \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/li>\n<\/ul>\n<p>  \u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e ExpressionTree \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0432\u0438\u0434\u0430 <b>Func&lt;object, TOut&gt;<\/b>. \u041f\u043b\u0430\u043d \u0442\u0430\u043a\u043e\u0439: \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 TOut \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (expression), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0440\u0430\u0437\u0443 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e <a href=\"https:\/\/github.com\/teoadal\/veloimplementations\/blob\/master\/src\/Velo\/Mapping\/CompiledMapper.cs\">CompiledMapper<\/a>. \u042f \u0432\u044b\u043d\u0435\u0441 \u0441\u044e\u0434\u0430 \u043b\u0438\u0448\u044c \u0443\u0437\u043b\u043e\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 object, \u0442\u043e \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 object.<\/p>\n<pre><code class=\"cs\">var parameter = Expression.Parameter(typeof(object), &quot;source&quot;); <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a Expression, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0430\u0436\u0435\u043d, \u0432\u0435\u0434\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0449\u0451 \u043d\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043d\u0430\u0438\u0432\u043d\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u0438\u0434\u0451\u043c \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0438\u0445 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<pre><code class=\"cs\">Expression sourceValue = Expression.Property(sourceInstance, sourceProperty); Expression outValue = Expression.Property(outInstance, outProperty);                      expressions.Add(Expression.Assign(outValue, sourceValue)); <\/code><\/pre>\n<p>  \u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c Expression, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438. \u042f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0440\u044f\u0434\u043e\u043c \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 return \u0432 ExpressionTree \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a? \u0411\u043e\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c.<\/p>\n<p>  \u041d\u0443 \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438. \u0427\u0442\u043e \u043d\u0430\u043c \u0442\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f body \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u00ab\u0442\u0435\u043b\u043e\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0423 \u00ab\u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439\u00bb \u0432\u0435\u0434\u044c \u0435\u0441\u0442\u044c \u0442\u0435\u043b\u043e, \u0432\u0435\u0440\u043d\u043e? \u041d\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. \u0422\u0430\u043a \u0432\u043e\u0442, Expression.Block \u2014 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u044d\u0442\u043e \u0435\u0449\u0451 \u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 sourceInstance \u0438 outInstance.<\/p>\n<pre><code class=\"cpp\">var body = Expression.Block(new[] {sourceInstance, outInstance}, expressions); return Expression.Lambda&lt;Func&lt;object, TOut&gt;&gt;(body, parameter).Compile(); <\/code><\/pre>\n<p>  \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c Func&lt;object, TOut&gt;, \u0442.\u0435. \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439. \u041a \u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b? \u042f \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c boxing&#8217;a \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 ValueType-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 PropertyInfo.GetValue \u0438 PropertyInfo.SetValue, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435. <\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 boxing? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 ExpressionTree \u044d\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 IL \u0438 \u0434\u043b\u044f runtime \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 (\u043f\u043e\u0447\u0442\u0438), \u043a\u0430\u043a \u0438 \u0432\u0430\u0448 \u043a\u043e\u0434. \u041f\u043e\u0447\u0435\u043c\u0443 \u00ab\u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 mapper\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435? \u0421\u043d\u043e\u0432\u0430: \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 IL. \u041a\u0441\u0442\u0430\u0442\u0438, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/dotnet\/BenchmarkDotNet\">BenchmarkDotNet<\/a>, \u0430 \u0441\u0430\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/teoadal\/veloimplementations\/blob\/master\/src\/Velo.Benchmark\/MappersBenchmark.cs\">\u0442\u0443\u0442<\/a>.   <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th> Method<\/th>\n<th> Mean<\/th>\n<th>Error<\/th>\n<th>StdDev<\/th>\n<th>Ratio<\/th>\n<th>Allocated<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>AutoMapper<\/td>\n<td>1,291.6 us<\/td>\n<td>3.3173 us<\/td>\n<td>3.1030 us<\/td>\n<td>1.00<\/td>\n<td>312.5 KB<\/td>\n<\/tr>\n<tr>\n<td>BasicMapper<\/td>\n<td>11,987.0 us<\/td>\n<td>33.8389 us<\/td>\n<td>28.2570 us<\/td>\n<td>9.28<\/td>\n<td>3437.5 KB<\/td>\n<\/tr>\n<tr>\n<td>CompiledMapper<\/td>\n<td>341.3 us<\/td>\n<td>2.8230 us<\/td>\n<td>2.6407 us<\/td>\n<td>0.26<\/td>\n<td>312.5 KB<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  \u0412 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 Ratio \u00ab\u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 mapper\u00bb (CompiledMapper) \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0434\u0430\u0436\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 AutoMapper (\u043e\u043d baseline, \u0442.\u0435. 1). \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f: AutoMapper \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0430\u0448\u0438\u043c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u043c. \u042d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u043e\u0439 \u044f \u043b\u0438\u0448\u044c \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e ExpressionTrees \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u00ab\u043f\u043e\u0434\u0445\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e Reflection\u00bb.<\/p>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 mapper \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. Reflection \u0438 ExpressionTrees \u2014 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. Dependency injection, Serialization\/Deserialization, CRUD-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f .NET-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Reflection, Reflection.Emit \u0438 ExpressionTrees.<\/p>\n<p>  \u0410 \u0447\u0442\u043e mapper? Mapper \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435\u043c\u0443 \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f.<\/p><\/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\/463961\/\"> https:\/\/habr.com\/ru\/post\/463961\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ry\/x_\/sj\/ryx_sj0phsfsrlfz1tcxy2_8izs.jpeg\" alt=\"image\"\/><\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 <a href=\"https:\/\/automapper.org\/\">AutoMapper<\/a>. \u0414\u0430, \u043c\u043d\u0435 \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e\u0431 \u044d\u0442\u043e\u043c, \u043d\u043e \u044f \u043d\u0435 \u0441\u043c\u043e\u0433\u0443. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u0438\u043c\u0435\u044e\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0431 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0439 \u043f\u0443\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u042f \u043b\u0438\u0448\u044c \u043c\u043e\u0433\u0443 \u0434\u0430\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0434\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0430\u043c\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u00ab\u043c\u0430\u043f\u043f\u0435\u0440\u043e\u0432\u00bb. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434.  <\/p>\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-293471","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293471","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=293471"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293471\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}