Книги - Внедрение зависимостей в .NET | Марк Симан

Page / - Изменено Alexandr Fokin в 2024/01/04 19:22

Внедрение зависимостей в .NET | Марк Симан

Изменено Alexandr Fokin

в 2024/01/04 19:22

Оглавление

В данной книге рассматриваются концепции DI и IOC. А также приводятся примеры взаимодействия с framework IOC контейнерами. Приводятся примеры паттернов и анти-паттернов. Управление жизненным циклом зависимостей.
Преобразование абстракций в конкретные типы (Процесс разрешения) DI - процесс внедрения типов при создании экземпляров. Poor man DI - ручное явное внедрение без использования DI(IOC) контейнера. DI(IOC) контейнер - инструмент позволяющий производить внедрение типов автоматически на основе некоторого, сконфигурированного пользователем, маппинга (абстракция -> тип) IOC подразумевает наличие библиотеки или фреймворка, контролирующего часть жизненного цикла приложения и предоставляющий интерфейс для реализации некоторый логики в рамках жизненного цикла разработчику. Типы внедрений: Внедрение в конструктор (обязательное) Внедрение в свойство (необязательное, предполагает возможность наличия значения по умолчанию) Внедрение в метод (внедрение при вызове метода) Фабрика
Не удалось выполнить макрос [html]. Причина: [When using HTML content inline, you can only use inline HTML content. Block HTML content (such as tables) cannot be displayed. Try leaving an empty line before and after the macro.]. Нажмите на это сообщение для получения подробной информации. org.xwiki.rendering.macro.MacroExecutionException: When using HTML content inline, you can only use inline HTML content. Block HTML content (such as tables) cannot be displayed. Try leaving an empty line before and after the macro. at org.xwiki.rendering.internal.transformation.macro.HTMLRawBlockFilter.cleanHTML(HTMLRawBlockFilter.java:133) at org.xwiki.rendering.internal.transformation.macro.HTMLRawBlockFilter.filter(HTMLRawBlockFilter.java:80) at org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter.filter(XWikiHTMLRawBlockFilter.java:63) at org.xwiki.rendering.internal.macro.html.HTMLMacro.execute(HTMLMacro.java:160) at org.xwiki.rendering.internal.macro.html.HTMLMacro.execute(HTMLMacro.java:70) at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:441) at org.xwiki.rendering.internal.transformation.DefaultRenderingContext.transformInContext(DefaultRenderingContext.java:183) at org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:88) at org.xwiki.display.internal.DocumentContentAsyncExecutor.executeInCurrentExecutionContext(DocumentContentAsyncExecutor.java:396) at org.xwiki.display.internal.DocumentContentAsyncExecutor.execute(DocumentContentAsyncExecutor.java:269) at org.xwiki.display.internal.DocumentContentAsyncRenderer.execute(DocumentContentAsyncRenderer.java:112) at org.xwiki.rendering.async.internal.block.AbstractBlockAsyncRenderer.render(AbstractBlockAsyncRenderer.java:157) at org.xwiki.rendering.async.internal.block.AbstractBlockAsyncRenderer.render(AbstractBlockAsyncRenderer.java:54) at org.xwiki.rendering.async.internal.DefaultAsyncRendererExecutor.syncRender(DefaultAsyncRendererExecutor.java:290) at org.xwiki.rendering.async.internal.DefaultAsyncRendererExecutor.render(DefaultAsyncRendererExecutor.java:267) at org.xwiki.rendering.async.internal.block.DefaultBlockAsyncRendererExecutor.execute(DefaultBlockAsyncRendererExecutor.java:125) at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:93) at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:46) at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:96) at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:39) at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:123) at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:52) at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:68) at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:42) at com.xpn.xwiki.doc.XWikiDocument.display(XWikiDocument.java:1431) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1567) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1534) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1449) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1576) at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:829) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:571) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:554) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:221) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:368) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:492) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:147) at org.apache.velocity.runtime.directive.Foreach.renderBlock(Foreach.java:309) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:279) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:304) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:439) at org.apache.velocity.Template.merge(Template.java:358) at org.apache.velocity.Template.merge(Template.java:262) at org.xwiki.velocity.internal.InternalVelocityEngine.evaluate(InternalVelocityEngine.java:233) at com.xpn.xwiki.internal.template.VelocityTemplateEvaluator.evaluateContent(VelocityTemplateEvaluator.java:107) at com.xpn.xwiki.internal.template.TemplateAsyncRenderer.evaluateContent(TemplateAsyncRenderer.java:219) at com.xpn.xwiki.internal.template.TemplateAsyncRenderer.renderVelocity(TemplateAsyncRenderer.java:174) at com.xpn.xwiki.internal.template.TemplateAsyncRenderer.render(TemplateAsyncRenderer.java:135) at com.xpn.xwiki.internal.template.TemplateAsyncRenderer.render(TemplateAsyncRenderer.java:54) at org.xwiki.rendering.async.internal.DefaultAsyncRendererExecutor.lambda$syncRender$0(DefaultAsyncRendererExecutor.java:284) at com.xpn.xwiki.internal.security.authorization.DefaultAuthorExecutor.call(DefaultAuthorExecutor.java:98) at org.xwiki.rendering.async.internal.DefaultAsyncRendererExecutor.syncRender(DefaultAsyncRendererExecutor.java:284) at org.xwiki.rendering.async.internal.DefaultAsyncRendererExecutor.render(DefaultAsyncRendererExecutor.java:267) at org.xwiki.rendering.async.internal.block.DefaultBlockAsyncRendererExecutor.render(DefaultBlockAsyncRendererExecutor.java:154) at com.xpn.xwiki.internal.template.InternalTemplateManager.render(InternalTemplateManager.java:907) at com.xpn.xwiki.internal.template.InternalTemplateManager.renderFromSkin(InternalTemplateManager.java:869) at com.xpn.xwiki.internal.template.InternalTemplateManager.renderFromSkin(InternalTemplateManager.java:849) at com.xpn.xwiki.internal.template.InternalTemplateManager.render(InternalTemplateManager.java:835) at com.xpn.xwiki.internal.template.DefaultTemplateManager.render(DefaultTemplateManager.java:91) at com.xpn.xwiki.internal.template.DefaultTemplateManager.render(DefaultTemplateManager.java:85) at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:2569) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:2547) at com.xpn.xwiki.pdf.impl.PdfExportImpl.export(PdfExportImpl.java:166) at com.xpn.xwiki.web.ExportAction.export(ExportAction.java:191) at com.xpn.xwiki.web.ExportAction.render(ExportAction.java:97) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:637) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:339) at com.xpn.xwiki.web.LegacyActionServlet.service(LegacyActionServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:61) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:209) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:656) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:397) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:935) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1833) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:975) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:493) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) at java.base/java.lang.Thread.run(Unknown Source)