{"id":334576,"date":"2022-06-16T09:00:51","date_gmt":"2022-06-16T09:00:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334576"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334576","title":{"rendered":"<span>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/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 loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/5b0\/ba8\/003\/5b0ba80038484fde4f99c0f107474c55.jpeg\" width=\"1200\" height=\"674\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5b0\/ba8\/003\/5b0ba80038484fde4f99c0f107474c55.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u0430\u0448\u0430 \u0436\u0438\u0437\u043d\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0430\u043d\u044f\u0442\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435\u043c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u2013 \u0438\u0437\u043b\u043e\u0436\u0443 \u0432\u0430\u043c \u043f\u043b\u0430\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 (\u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e) \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u0435 \u043d\u0430 Visual Studio \u0438 JustMock \u0432\u0441\u044e \u0442\u044f\u0436\u0435\u043b\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>\u041b\u044e\u0431\u043b\u044e \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043e\u0440\u0432\u0430\u043d\u044b \u043e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u043d\u0435\u043a\u043e\u0435 \u0441\u0432\u0435\u0436\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430, \u043d\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u2013 \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0441\u0442\u043d\u044b \u2013 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442. \u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0442 70% \u0434\u043e 90% \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435, \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0438 (\u0438\u043d\u043e\u0433\u0434\u0430) \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0410 \u044f \u0435\u0449\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0432\u0430\u043c \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0437\u0430 \u043e\u0431\u0432\u044f\u0437\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0442\u0430\u043a\u0438\u0445 \u00ab\u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445\/\u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0442\u0430\u043a\u0438\u0435 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u043c\u0435\u043d\u044f\u0435\u0442\u0435<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 (<a href=\"https:\/\/www.telerik.com\/products\/mocking.aspx\">Telerik JustMock<\/a>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0435 \u043c\u0435\u0441\u0442\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443 <\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u0442\u0430\u043a \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 (\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e). \u041e\u043f\u0430\u0441\u043d\u0430\u044f \u0437\u043e\u043d\u0430 \u2013 \u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u2013 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0432\u043d\u043e\u0441\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u0421\u043f\u043e\u0439\u043b\u0435\u0440:<\/strong>\u00a0\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433.<\/p>\n<h2>\u041a\u0435\u0439\u0441 \u043e\u0431 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0435\u0439\u0441\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u0430. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ASP.NET MVC, \u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0441 \u043d\u0438\u043c \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c, \u0432 \u0440\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0441 WebForms, \u0438 \u0441 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. (<a href=\"https:\/\/www.telerik.com\/docs\/default-source\/blogs-docs\/legacycodetestingstart.zip\">\u0412\u043e\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>, \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0432\u043d\u0435\u0441\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.)<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u0432\u0430\u0440 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u0438 (\u0412\u044b\u0441\u043e\u043a\u0438\u0439, \u0421\u0440\u0435\u0434\u043d\u0438\u0439, \u041d\u0438\u0437\u043a\u0438\u0439). \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0449\u0435\u043b\u043a\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u00abSubmit\u00bb (\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c) \u2013 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u0438\u0448\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f ShippingManager \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: \u043e\u0431\u044a\u0435\u043a\u0442 <code>Product<\/code> (\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0435\u0441, \u0432\u044b\u0441\u043e\u0442\u0430, \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u043e\u0441\u043e\u0431\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00ab\u041d\u0435 \u043a\u0430\u043d\u0442\u043e\u0432\u0430\u0442\u044c\u00bb), \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0438 \u0441\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0417\u0430\u0442\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0441\u0435\u0439 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0418\u0437\u043b\u0438\u0448\u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043e\u043d\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044f\u043c\u0438).<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg) {    \/\/\u2026\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434\u2026    **decimal shipCost = CalcShipCost(prod, qty, urg);**    \/\/\u2026\u0435\u0449\u0435 \u043a\u043e\u0434\u2026     ShipAcceptModel model = new ShipAcceptModel();    model.ShipCost = shipCost;    return View(model); }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <code>CalcShippingCost<\/code>, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u044b\u043b \u0431\u0435\u0437\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u043d\u043e \u00ab\u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c\u00bb \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (FedEx, UPS, USPS, \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c).<\/p>\n<p>\u042f \u0432\u0438\u0436\u0443 \u0442\u0443\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f (\u0434\u0432\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0441\u0435\u0431\u0435 \u0441\u0430\u043c):<\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043d\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0445\u043e\u0434\u0435 \u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u043c\u043d\u0435 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0438 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c: \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u0432\u043d\u043e\u0448\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2013 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 (\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 (\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u043a\u043e\u0434\u0430 <\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u043e\u0434 \u2013 \u044d\u0442\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 <code>CalcShipCosts<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u043e\u0440\u0430 (switch), \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u0447\u0442\u043e \u043d\u0430\u0434\u043e. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0412\u0435\u0434\u044c \u0443 \u0432\u0430\u0441, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u2013 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0430\u043a\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCosts<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c. \u041f\u0440\u0438 \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0432\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u2013 \u043a\u0430\u043a \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u0442\u0430\u043a \u0438 \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0442\u0430\u043a \u0438 \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0444\u043e\u043a\u0443\u0441\u0430\u043c\u0438 \u0438\u0437 Visual Studio, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0434\u0430\u043b\u0435\u0435 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0438 \u0447\u0430\u0441\u0430 \u0445\u0432\u0430\u0442\u0438\u0442), \u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e, \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410 \u0435\u0449\u0435 \u0443 \u0432\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2013 \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a, \u0432\u0438\u0448\u0435\u043d\u043a\u0430 \u043d\u0430 \u0442\u043e\u0440\u0442\u0435. \u00a0<\/p>\n<p>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u0434 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ShipProduct<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a (\u0430 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f):<\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg, ShippingMethod meth) {    IShippingStrategy sStrat = new OriginalShip();    switch(meth)    {        case ShippingMethod.USPS:                     sStrat = new USPSShip();                      break;        case ShippingMethod.FedEx:                     sStrat = new FedexShip();                      break;       \/\/\u2026\u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438\u2026    }    decimal shipCost = CalcShipCost(prod, qty, urg, sStrat);     ShipAcceptModel model = new ShipAcceptModel();    model.ShipCost = shipCost;    return View(model); }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0447\u0435\u043c, \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0432\u0435\u043b \u043a\u043e\u0434 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0437\u0434\u0435\u0441\u044c, \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0432 \u0432\u0441\u0435 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0432\u043e\u043b\u043d\u0438\u0441\u0442\u044b\u0435 \u043b\u0438\u043d\u0438\u0438, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 Visual Studio \u2013 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e\u043d\u0430 \u0436\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0430 \u043e\u0431 \u044d\u0442\u0438\u0445 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (FedExShip, UPSShip, \u0434\u0440.) \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 (\u043d\u0430\u0437\u043e\u0432\u0443 \u0438\u0445 \u00ab\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438\u00bb). \u0427\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u043c\u043e\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IShipping<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u043e\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 &#8212; \u043f\u0440\u0438\u043a\u0430\u0436\u0443 Visual Studio \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043c\u043e\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b. \u041d\u0430\u0432\u0435\u0434\u0443 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0443, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u043d\u0430 <code>IShippingStrategy<\/code>, \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0443\u043c\u043d\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u0438\u0445 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043c\u0435\u043d\u044e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u201cGenerate Interface \u2018<code>IShippingStrategy<\/code>\u2019 in a new file\u201d (\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u2018IShippingStrategy\u2019 \u0432 \u043d\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435). \u041f\u0440\u043e\u0434\u0435\u043b\u0430\u044e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2013 \u0438 \u0432\u043e\u0442 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cfe\/482\/bca\/cfe482bcaed97db071e21899b5ab309a.png\" alt=\"\" title=\"\" width=\"1316\" height=\"414\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfe\/482\/bca\/cfe482bcaed97db071e21899b5ab309a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 <code>ShippingMethod<\/code> \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435 \u043b\u0435\u0433\u043a\u043e: \u0449\u0435\u043b\u043a\u0430\u044e \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u0434\u0435 \u043f\u043e <code>ShippingMethod<\/code> \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e \u201cGenerate new type.\u201d (\u00ab\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f\u00bb).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/077\/7ed\/88a\/0777ed88a06b1a66fd158643a8a59e10.png\" width=\"1155\" height=\"451\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/077\/7ed\/88a\/0777ed88a06b1a66fd158643a8a59e10.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e: \u0445\u043e\u0447\u0443, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0431\u044b\u043b \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043d\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u0429\u0435\u043b\u043a\u0430\u044e OK \u2013 \u0438, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5dc\/f0b\/9d1\/5dcf0b9d1887a7e0d2537eac2ff82d77.png\" width=\"697\" height=\"567\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5dc\/f0b\/9d1\/5dcf0b9d1887a7e0d2537eac2ff82d77.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, Visual Studio \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0430 \u044d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0443 \u00abControllers\u00bb (\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b). \u0412 \u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0420\u0435\u0448\u0435\u043d\u0438\u0439 (Solution Explorer) \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0443 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0445\u043e\u0447\u0443 \u0438\u0445 \u0432\u0438\u0434\u0435\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0432 \u043f\u0430\u043f\u043a\u0443 \u00abModels\u00bb (\u041c\u043e\u0434\u0435\u043b\u0438). \u0414\u0435\u043b\u0430\u044f \u044d\u0442\u043e, \u0438\u0437\u043c\u0435\u043d\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043d\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044e \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0438\u0445 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044e \u043c\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (USPS, FedEx, \u0442.\u0434.).<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 IShippingStrategy, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0432\u0432\u0435\u043b. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u0432\u0435\u0434\u0443 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043a <code>CalcShipCost<\/code>, \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0443\u043c\u043d\u043e\u043c\u0443 \u0442\u0435\u0433\u0443 \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u201cAdd parameter to \u2026\u201d (\u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u2026\u00bb). Visual Studio \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442 \u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0df\/e46\/a35\/0dfe46a35aebe38bd51ad8f40b3d27a6.png\" width=\"1799\" height=\"386\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0df\/e46\/a35\/0dfe46a35aebe38bd51ad8f40b3d27a6.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f.<\/h2>\n<p>\u042f \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044e\u0441\u044c \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>CalcShipCost<\/code> \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u043c \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044f \u0432\u044b\u0440\u0435\u0436\u0443 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e\u0441\u044f <code>CalcShipCost<\/code> \u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>OriginalShip<\/code> (\u0432\u043d\u0443\u0442\u0440\u044c \u043d\u0435\u0433\u043e \u044f \u043f\u043e\u043b\u043e\u0436\u0443 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043e\u0432\u0443 <code>CalcMethodCost<\/code>).<\/p>\n<p>\u0422\u043e\u0447\u043d\u0435\u0435: \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c Visual Studio \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430 \u043c\u0435\u043d\u044f.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u043a\u043e\u0434\u0430 \u2013 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0443\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c switch-\u0431\u043b\u043e\u043a\u00bb):<\/p>\n<pre><code class=\"cs\">private decimal CalcShipCost(IProduct prod, int qty, ShippingUrgency urg, IShippingStrategy sStrat) {    decimal extraCharges = 0;    bool areExtraCharges = false;     \/\/ \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438    decimal shippingCost = 0;   if (prod.weight > 100)   {      shippingCost += 100 * SalesTax;   }   if (qty &lt; 50) { \u2026.more code \u2026}  switch (urg)  {      \u2026various case statements  }   \/\/\u2026 \u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430    \/\/ \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u0432\u0430\u0440    if (areExtraCharges)   {      shippingCost += extraCharges;   }   \/\/\u2026\u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430\u2026    return shippingCost; } <\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u2013 \u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u0437\u044f\u043b\u0441\u044f <code>SalesTax<\/code> \u2013 \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043e\u0434\u043d\u043e \u0438\u0437 \u0442\u0435\u0445 \u043f\u043e\u043b\u0435\u0439, \u0447\u0442\u043e \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u0432\u0441\u044e\u0434\u0443. \u00a0<\/p>\n<p>\u041c\u043d\u0435 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u00ab\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u00bb, \u0435\u0441\u043b\u0438 \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c Visual Studio \u0438 \u0441\u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0432\u044b\u0434\u0435\u043b\u044e \u0432 \u043c\u043e\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>CalcShipCost<\/code> \u0442\u043e\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0443 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0429\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u0438\u0437 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u043d\u044e \u00abQuick Actions and Refactorings\u00bb (\u0411\u044b\u0441\u0442\u0440\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0aa\/ae7\/4e9\/0aaae74e94748753dc00be18c95b446c.png\" width=\"1064\" height=\"392\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0aa\/ae7\/4e9\/0aaae74e94748753dc00be18c95b446c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0432\u044b\u0431\u0435\u0440\u0443 \u201cExtract Method.\u201d (\u0418\u0437\u0432\u043b\u0435\u0447\u044c \u043c\u0435\u0442\u043e\u0434).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/266\/e2b\/b4c\/266e2bb4c48eccef84f32a6018947b06.png\" width=\"1422\" height=\"878\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/266\/e2b\/b4c\/266e2bb4c48eccef84f32a6018947b06.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0449\u0435\u043b\u043a\u0430\u0435\u0442\u0435 \u0432 \u043c\u0435\u043d\u044e \u043f\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443 Extract Method, Visual Studio \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u043e\u0442 \u043a\u043e\u0434, \u0447\u0442\u043e \u044f \u0432\u044b\u0434\u0435\u043b\u0438\u043b, \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f (\u0445\u0438\u0442\u0440\u043e!) <code>NewMethod<\/code>. \u042f \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u044e <code>NewMethod<\/code> \u0432 <code>CalcMethodCost<\/code> \u0432 \u043c\u043e\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u044e \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u00abApply\u00bb (\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c). Visual Studio \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aaa\/fc6\/33f\/aaafc633fdfa5cde3fb84941b6bf22d4.png\" width=\"1400\" height=\"370\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aaa\/fc6\/33f\/aaafc633fdfa5cde3fb84941b6bf22d4.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0429\u0435\u043b\u043a\u0430\u044e \u043f\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u044e F12, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043c\u0435\u0442\u043e\u0434\u0443. \u041e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u043d\u0435\u043c, \u044f \u0432\u044b\u0440\u0435\u0437\u0430\u044e \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>ShippingManager<\/code> \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0435\u0433\u043e \u0432 \u043c\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 <code>OriginalShip<\/code>: \u0432\u043e\u0442 \u0443 \u043c\u0435\u043d\u044f \u0438 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f. \u0423\u0434\u0430\u043b\u044f\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 static \u0438 \u043c\u0435\u043d\u044f\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u043d\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u0432 <code>CalcShipCost<\/code>, \u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>IShippingStrategy<\/code>:<\/p>\n<pre><code class=\"cs\">private decimal CalcShipCost(IProduct prod, int qty, ShippingUrgency urg, IShippingStrategy sStrat) {    decimal extraCharges = 0;    bool areExtraCharges = false;     **shippingCost = sStrat.CalcMethodCost(prod, qty, urg);**     if (areExtraCharges)    {       shippingCost += extraCharges;    }    \/\/\u2026\u0435\u0449\u0435 \u043a\u043e\u0434\u2026     return shippingCost; }<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0438 \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:<\/p>\n<pre><code class=\"cs\">public class OriginalShip: IShippingStrategy {    public decimal CalcMethodCost(IProduct prod, int qty, ShippingUrgency urg)    {       \/\/\u2026\u043a\u043e\u0434 \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u2026    } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0433\u0443 \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441: \u043a\u043e\u043f\u0438\u0440\u0443\u044e \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u043c\u043e\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>CalcMethodCost<\/code>, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0435\u0435 \u0432 <code>IShippingStrategy<\/code>, \u0443\u0434\u0430\u043b\u044f\u044e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u0432\u043b\u044e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u043e\u0447\u043a\u0443 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439:<\/p>\n<pre><code class=\"cs\">\u0432 IShippingStrategy, \u0443\u0434\u0430\u043b\u044f\u044e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0430\u0432\u043b\u044e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u043e\u0447\u043a\u0443 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439: \/\/ \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u00ab\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u00bb public interface IShippingStrategy {    decimal CalcMethodCost(IProduct prod, int qty, ShippingUrgency urg); }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u044e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b Visual Studio \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0430, \u0447\u0442\u043e \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>OriginalShip<\/code> \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f <code>SalesTax<\/code> (\u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0443\u0436 \u043d\u0430 \u0442\u043e \u043f\u043e\u0448\u043b\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0438\u0437 <code>ShippingManager<\/code>). \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2013 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>SalesTax<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0443 \u043a <code>CalcMethodCost<\/code> \u0438 \u0432\u043d\u043e\u0432\u044c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u201cAdd parameter to \u2026\u201d. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044e \u043c\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a <code>CalcMethodCost<\/code> \u0432 <code>OriginalShip<\/code> \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IShippingStrategy<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u043f\u0440\u0438\u043a\u0430\u0436\u0443 Visual Studio \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439: \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0443\u043c\u043d\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f, \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u201cImplement Interface.\u201d (\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441). \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u043e\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u0445 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>CalcMethodCost<\/code>, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u0447\u0442\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d. <\/p>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u0434 \u0444\u0430\u0431\u0440\u0438\u043a\u0438<\/h2>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0435\u043b\u043e \u043f\u043e\u0448\u043b\u043e \u0442\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e (\u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0430 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0443 \u043c\u0435\u043d\u044f \u0443\u0448\u043b\u043e \u043c\u0435\u043d\u0435\u0435 \u0447\u0430\u0441\u0430), \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>ShipProduct<\/code> \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043a\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0441\u0438\u0434\u0438\u0442 \u0432 \u043c\u043e\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0420\u0435\u0448\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u00bb \u2014 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0431\u043b\u043e\u043a \u0432\u044b\u0431\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0438 \u0441\u0434\u0435\u043b\u0430\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0441\u0432\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u201c\u043d\u0430\u0448\u0430 \u043f\u0435\u0441\u043d\u044f \u0445\u043e\u0440\u043e\u0448\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u0439 \u0441\u043d\u0430\u0447\u0430\u043b\u0430\u201d: \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430 \u0432 <code>ShippingManager<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043c\u043e\u0435\u0433\u043e \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043a\u0430\u0437\u044b\u0432\u0430\u044e Visual Studio \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441. \u0412\u044b\u0431\u0438\u0440\u0430\u044e \u0431\u043b\u043e\u043a switch \u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u00abExtract\u00bb (\u0418\u0437\u0432\u043b\u0435\u0447\u044c) \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u044d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u0432 \u043c\u0435\u0442\u043e\u0434. \u041d\u0430\u0436\u0430\u0432 F12, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u044f \u0432\u044b\u0440\u0435\u0437\u0430\u044e \u0435\u0433\u043e \u0438\u0437 <code>ShippingManager<\/code> \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432 \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0435\u0440\u0435\u0435\u0434\u0435\u0442, \u044f \u0443\u0431\u0438\u0440\u0430\u044e \u0432 \u043d\u0435\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>static<\/code> \u0438 \u043c\u0435\u043d\u044f\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u043d\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e. \u041a\u043b\u0430\u0441\u0441 \u044f \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u044e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c, \u043c\u0435\u043d\u044f\u044e \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u044e \u043a\u043b\u0430\u0441\u0441 \u0432 \u043f\u0430\u043f\u043a\u0443 \u00abModels\u00bb (\u041c\u043e\u0434\u0435\u043b\u0438). \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u044f \u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 <code>ShippingManager<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg, ShippingMethod meth) {    \/\/\u2026 \u0435\u0449\u0435 \u043a\u043e\u0434    ShippingMethodFactory smf = new ShippingMethodFactory();    IShippingStrategy sStrat = smf.GetShippingMethod(meth);    decimal shipCost = CalcShipCost(prod, qty, urg, meth, sStrat);    \/\/\u2026 \u0435\u0449\u0435 \u043a\u043e\u0434    return View(model); }<\/code><\/pre>\n<p>\u041c\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 <code>ShippingMethodFactory<\/code> \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442 \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public class ShippingMethodFactory {    public IShippingStrategy GetShippingMethod(ShippingMethod meth)    {       IShippingStrategy sStrat = new OriginalShip();       switch (meth)       {         \/\/\u2026 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u2026       }       return sStrat;    } }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0443\u0445\u043e\u0434\u0438\u0442 \u0435\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u044f\u0442\u044c \u043c\u0438\u043d\u0443\u0442. \u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u044f \u0441\u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0430 \u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 CalcShipCost \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0432 \u043f\u043e\u043a\u043e\u0435.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430: \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043c\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0415\u0441\u043b\u0438 \u044f \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u044e, \u0442\u043e, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c GetShippingMethod \u2013 \u0438 \u043d\u0435 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0448\u044c \u0432 \u043e\u0442\u0432\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<h2>\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043e\u0441\u043e\u0437\u043d\u0430\u044e, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u044e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u0432\u044b\u0437\u043e\u0432 <code>CalcShipCost<\/code> \u0432 \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043c\u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430 \u2013 \u0442\u0435\u0441\u0442 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0421\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u0438\u043c \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e Visual Studio, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b\u0430 \u043c\u043e\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ShipProduct<\/code> \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: ShippingMethodFactory smf = new ShippingMethodFactory(); IShippingStrategy sStrat = smf.GetShippingMethod(meth); decimal shipCost = CalcShipCost(prod, qty, urg, meth, sStrat);<\/code><\/pre>\n<p>\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cs\">ShippingCostCalculator scc = new ShippingCostCalculator(); decimal shipCost = scc.CalcShipping(prod, qty, urg, meth, SalesTax); <\/code><\/pre>\n<p>\u041c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438\u043c\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">public class ShippingCostCalculator {   public decimal CalcShipping(IProduct prod, int qty, ShippingUrgency urg, ShippingMethod meth, decimal salesTax)   {       ShippingMethodFactory smf = new ShippingMethodFactory();       IShippingStrategy sStrat = smf.GetShippingMethod(meth);       return CalcShipCost(prod, qty, urg, sStrat, salesTax);   }   private decimal CalcShipCost(IProduct prod, int qty, ShippingUrgency urg, decimal salesTax )   {      \/\/\u2026\u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u2026 }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u044f \u0441\u043c\u043e\u0433\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u0438 \u044d\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043a\u0430\u043a\u0438\u0445 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441.<\/p>\n<p><a href=\"https:\/\/www.telerik.com\/docs\/default-source\/blogs-docs\/legacyunittestingend.zip\">\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u043a\u0430\u043a\u043e\u0439 \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/a><\/p>\n<h2>\u041e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430\u0437\u0430\u0434<\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u0447\u0435\u043c \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u0437\u0434\u0435\u0441\u044c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435, \u0447\u0442\u043e \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0420\u0435\u0448\u0438\u0442\u044c, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 (\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0442\u043e\u0432\u0430\u0440\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e, \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d, \u0432\u044b\u043d\u0435\u0441\u0442\u0438 ShippingCostCalculator \u0432 \u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f.)<\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b \u043d\u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0438\u0437\u0430\u0439\u043d \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u0441\u044f. \u041c\u044b \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043e\u0442 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 (<code>ShippingCostCalculator<\/code>), \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 (<code>ShippingMethodFactory<\/code>) \u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043d\u0430\u0448\u0438\u043c \u0431\u0438\u0437\u043d\u0435\u0441\u043e\u043c (FedExShip, UPSShip, etc.).<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0432 \u043d\u0430 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0447\u0430\u0441-\u043f\u043e\u043b\u0442\u043e\u0440\u0430, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u2013 \u043f\u043e \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438 \u2013 \u043f\u043e\u0434\u0434\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/piter\/blog\/671612\/\"> https:\/\/habr.com\/ru\/company\/piter\/blog\/671612\/<\/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\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u0430\u0448\u0430 \u0436\u0438\u0437\u043d\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0430\u043d\u044f\u0442\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435\u043c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u2013 \u0438\u0437\u043b\u043e\u0436\u0443 \u0432\u0430\u043c \u043f\u043b\u0430\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 (\u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e) \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u0435 \u043d\u0430 Visual Studio \u0438 JustMock \u0432\u0441\u044e \u0442\u044f\u0436\u0435\u043b\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>\u041b\u044e\u0431\u043b\u044e \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043e\u0440\u0432\u0430\u043d\u044b \u043e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u043d\u0435\u043a\u043e\u0435 \u0441\u0432\u0435\u0436\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430, \u043d\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u2013 \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0441\u0442\u043d\u044b \u2013 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442. \u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0442 70% \u0434\u043e 90% \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435, \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0438 (\u0438\u043d\u043e\u0433\u0434\u0430) \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0410 \u044f \u0435\u0449\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0432\u0430\u043c \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0437\u0430 \u043e\u0431\u0432\u044f\u0437\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0442\u0430\u043a\u0438\u0445 \u00ab\u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445\/\u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0442\u0430\u043a\u0438\u0435 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u043c\u0435\u043d\u044f\u0435\u0442\u0435<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 (<a href=\"https:\/\/www.telerik.com\/products\/mocking.aspx\">Telerik JustMock<\/a>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0435 \u043c\u0435\u0441\u0442\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443 <\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u043b\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u0442\u0430\u043a \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 (\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e). \u041e\u043f\u0430\u0441\u043d\u0430\u044f \u0437\u043e\u043d\u0430 \u2013 \u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u2013 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0432\u043d\u043e\u0441\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u0421\u043f\u043e\u0439\u043b\u0435\u0440:<\/strong>\u00a0\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433.<\/p>\n<h2>\u041a\u0435\u0439\u0441 \u043e\u0431 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0435\u0439\u0441\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u0430. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ASP.NET MVC, \u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0441 \u043d\u0438\u043c \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c, \u0432 \u0440\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0441 WebForms, \u0438 \u0441 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. (<a href=\"https:\/\/www.telerik.com\/docs\/default-source\/blogs-docs\/legacycodetestingstart.zip\">\u0412\u043e\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>, \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0432\u043d\u0435\u0441\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.)<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u0432\u0430\u0440 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u0438 (\u0412\u044b\u0441\u043e\u043a\u0438\u0439, \u0421\u0440\u0435\u0434\u043d\u0438\u0439, \u041d\u0438\u0437\u043a\u0438\u0439). \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0449\u0435\u043b\u043a\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u00abSubmit\u00bb (\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c) \u2013 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0433\u0434\u0435-\u0442\u043e \u0432 \u043a\u0438\u0448\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f ShippingManager \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: \u043e\u0431\u044a\u0435\u043a\u0442 <code>Product<\/code> (\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0435\u0441, \u0432\u044b\u0441\u043e\u0442\u0430, \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u043e\u0441\u043e\u0431\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00ab\u041d\u0435 \u043a\u0430\u043d\u0442\u043e\u0432\u0430\u0442\u044c\u00bb), \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0438 \u0441\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0417\u0430\u0442\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0441\u0435\u0439 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0418\u0437\u043b\u0438\u0448\u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043e\u043d\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044f\u043c\u0438).<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg) {    \/\/\u2026\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434\u2026    **decimal shipCost = CalcShipCost(prod, qty, urg);**    \/\/\u2026\u0435\u0449\u0435 \u043a\u043e\u0434\u2026     ShipAcceptModel model = new ShipAcceptModel();    model.ShipCost = shipCost;    return View(model); }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <code>CalcShippingCost<\/code>, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u044b\u043b \u0431\u0435\u0437\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u043d\u043e \u00ab\u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c\u00bb \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (FedEx, UPS, USPS, \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c).<\/p>\n<p>\u042f \u0432\u0438\u0436\u0443 \u0442\u0443\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f (\u0434\u0432\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0441\u0435\u0431\u0435 \u0441\u0430\u043c):<\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043d\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0445\u043e\u0434\u0435 \u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u043c\u043d\u0435 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0438 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c: \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u0432\u043d\u043e\u0448\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2013 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 (\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 (\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f) \u043a\u043e\u0434\u0430 <\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u043e\u0434 \u2013 \u044d\u0442\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 <code>CalcShipCosts<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0431\u043e\u0440\u0430 (switch), \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u0447\u0442\u043e \u043d\u0430\u0434\u043e. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0412\u0435\u0434\u044c \u0443 \u0432\u0430\u0441, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u2013 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0430\u043a\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCosts<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c. \u041f\u0440\u0438 \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0432\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u2013 \u043a\u0430\u043a \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u0442\u0430\u043a \u0438 \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0442\u0430\u043a \u0438 \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0444\u043e\u043a\u0443\u0441\u0430\u043c\u0438 \u0438\u0437 Visual Studio, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0434\u0430\u043b\u0435\u0435 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0438 \u0447\u0430\u0441\u0430 \u0445\u0432\u0430\u0442\u0438\u0442), \u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e, \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410 \u0435\u0449\u0435 \u0443 \u0432\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2013 \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a, \u0432\u0438\u0448\u0435\u043d\u043a\u0430 \u043d\u0430 \u0442\u043e\u0440\u0442\u0435. \u00a0<\/p>\n<p>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u043e\u0434 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ShipProduct<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a (\u0430 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f):<\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg, ShippingMethod meth) {    IShippingStrategy sStrat = new OriginalShip();    switch(meth)    {        case ShippingMethod.USPS:                     sStrat = new USPSShip();                      break;        case ShippingMethod.FedEx:                     sStrat = new FedexShip();                      break;       \/\/\u2026\u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438\u2026    }    decimal shipCost = CalcShipCost(prod, qty, urg, sStrat);     ShipAcceptModel model = new ShipAcceptModel();    model.ShipCost = shipCost;    return View(model); }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0447\u0435\u043c, \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0432\u0435\u043b \u043a\u043e\u0434 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0437\u0434\u0435\u0441\u044c, \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0432 \u0432\u0441\u0435 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0432\u043e\u043b\u043d\u0438\u0441\u0442\u044b\u0435 \u043b\u0438\u043d\u0438\u0438, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 Visual Studio \u2013 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e\u043d\u0430 \u0436\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0430 \u043e\u0431 \u044d\u0442\u0438\u0445 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (FedExShip, UPSShip, \u0434\u0440.) \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 (\u043d\u0430\u0437\u043e\u0432\u0443 \u0438\u0445 \u00ab\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438\u00bb). \u0427\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0445 \u043c\u043e\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IShipping<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u043e\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 &#8212; \u043f\u0440\u0438\u043a\u0430\u0436\u0443 Visual Studio \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043c\u043e\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b. \u041d\u0430\u0432\u0435\u0434\u0443 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0443, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u043d\u0430 <code>IShippingStrategy<\/code>, \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0443\u043c\u043d\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u0438\u0445 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043c\u0435\u043d\u044e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u201cGenerate Interface \u2018<code>IShippingStrategy<\/code>\u2019 in a new file\u201d (\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u2018IShippingStrategy\u2019 \u0432 \u043d\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435). \u041f\u0440\u043e\u0434\u0435\u043b\u0430\u044e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u2013 \u0438 \u0432\u043e\u0442 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 <code>ShippingMethod<\/code> \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435 \u043b\u0435\u0433\u043a\u043e: \u0449\u0435\u043b\u043a\u0430\u044e \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u0434\u0435 \u043f\u043e <code>ShippingMethod<\/code> \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e \u201cGenerate new type.\u201d (\u00ab\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f\u00bb).<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e: \u0445\u043e\u0447\u0443, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0431\u044b\u043b \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043d\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u0429\u0435\u043b\u043a\u0430\u044e OK \u2013 \u0438, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, Visual Studio \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0430 \u044d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0443 \u00abControllers\u00bb (\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b). \u0412 \u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0420\u0435\u0448\u0435\u043d\u0438\u0439 (Solution Explorer) \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0443 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0445\u043e\u0447\u0443 \u0438\u0445 \u0432\u0438\u0434\u0435\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0432 \u043f\u0430\u043f\u043a\u0443 \u00abModels\u00bb (\u041c\u043e\u0434\u0435\u043b\u0438). \u0414\u0435\u043b\u0430\u044f \u044d\u0442\u043e, \u0438\u0437\u043c\u0435\u043d\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043d\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044e \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0438\u0445 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044e \u043c\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (USPS, FedEx, \u0442.\u0434.).<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 IShippingStrategy, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0432\u0432\u0435\u043b. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u0432\u0435\u0434\u0443 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043a <code>CalcShipCost<\/code>, \u0449\u0435\u043b\u043a\u043d\u0443 \u043f\u043e \u0443\u043c\u043d\u043e\u043c\u0443 \u0442\u0435\u0433\u0443 \u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u201cAdd parameter to \u2026\u201d (\u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u2026\u00bb). Visual Studio \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442 \u043c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f.<\/h2>\n<p>\u042f \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044e\u0441\u044c \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>CalcShipCost<\/code> \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u043c \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044f \u0432\u044b\u0440\u0435\u0436\u0443 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e\u0441\u044f <code>CalcShipCost<\/code> \u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u043c\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>OriginalShip<\/code> (\u0432\u043d\u0443\u0442\u0440\u044c \u043d\u0435\u0433\u043e \u044f \u043f\u043e\u043b\u043e\u0436\u0443 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043e\u0432\u0443 <code>CalcMethodCost<\/code>).<\/p>\n<p>\u0422\u043e\u0447\u043d\u0435\u0435: \u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c Visual Studio \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430 \u043c\u0435\u043d\u044f.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CalcShipCost<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u043a\u043e\u0434\u0430 \u2013 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0443\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c switch-\u0431\u043b\u043e\u043a\u00bb):<\/p>\n<pre><code class=\"cs\">private decimal CalcShipCost(IProduct prod, int qty, ShippingUrgency urg, IShippingStrategy sStrat) {    decimal extraCharges = 0;    bool areExtraCharges = false;     \/\/ \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438    decimal shippingCost = 0;   if (prod.weight > 100)   {      shippingCost += 100 * SalesTax;   }   if (qty &lt; 50) { \u2026.more code \u2026}  switch (urg)  {      \u2026various case statements  }   \/\/\u2026 \u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430    \/\/ \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u0432\u0430\u0440    if (areExtraCharges)   {      shippingCost += extraCharges;   }   \/\/\u2026\u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430\u2026    return shippingCost; } <\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u2013 \u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u0437\u044f\u043b\u0441\u044f <code>SalesTax<\/code> \u2013 \u044d\u0442\u043e<\/p>\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-334576","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334576","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=334576"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334576\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}