ioc-container

How to Inject Dependencies to Dynamically Loaded Assemblies

 ̄綄美尐妖づ 提交于 2020-04-10 18:07:21
问题 I have a manager class that loads various plug-in modules contained in separate assemblies through reflection. This modules are communication to the outside world (WebAPI, various other web protocols). public class Manager { public ILogger Logger; // Modules need to access this. private void LoadAssemblies() { // Load assemblies through reflection. } } These plug-in modules must communicate with an object contained within the manager class. How can I implement this? I thought about using

Laravel IOC not calling the constructor

坚强是说给别人听的谎言 提交于 2020-03-05 04:59:47
问题 I have binding in the service provider $this->app->singleton( 'App\Models\Subscription\Interfaces\IInvoiceService', 'App\Models\Subscription\Impl\InvoiceService' ); class InvoiceService implements IInvoiceService { protected $repo; public function _construct(){ $this->app = App::getFacadeRoot(); $this->repo = $this->app['repo']; } public function Create() { } } In one of the classes in Injected the IInovoice Service. I am getting the concrete implementation of IInovoice . but the Constructor

How Spring Ioc container interacts with Tomcat container

。_饼干妹妹 提交于 2020-02-17 13:46:50
问题 I am familiar with the Spring Framework and have done some work in it. In one of my interviews, I was asked "there is a web application deployed in Apache Tomcat ; tell me how does the "Tomcat container" (used for servlets) interact with "Spring IoC container" (used for Spring beans)?" I couldn't understand what the interviewer meant by that and was left speechless. Can someone please clarify what this question was about and what a reasonable answer to it might be? 回答1: A spring web-app will

How Spring Ioc container interacts with Tomcat container

六眼飞鱼酱① 提交于 2020-02-17 13:43:09
问题 I am familiar with the Spring Framework and have done some work in it. In one of my interviews, I was asked "there is a web application deployed in Apache Tomcat ; tell me how does the "Tomcat container" (used for servlets) interact with "Spring IoC container" (used for Spring beans)?" I couldn't understand what the interviewer meant by that and was left speechless. Can someone please clarify what this question was about and what a reasonable answer to it might be? 回答1: A spring web-app will

StructureMap - Ability to replace an assembly at runtime

与世无争的帅哥 提交于 2020-02-08 02:42:07
问题 Example: Console application: class Program { static void Main(string[] args) { var calculator = ObjectFactory.GetInstance<ICalculator>(); for (var i = 0; i < 10; i++) { Console.WriteLine(calculator.Calculate(10, 5)); Console.ReadLine(); } Console.ReadLine(); } } Assembly "Interface": public interface ICalculator { int Calculate(int a, int b); } Assembly "Implemenation": internal class Calculator : ICalculator { public int Calculate(int a, int b) { return a + b; } } Assembly "Implemenation",

StructureMap - Ability to replace an assembly at runtime

a 夏天 提交于 2020-02-08 02:42:07
问题 Example: Console application: class Program { static void Main(string[] args) { var calculator = ObjectFactory.GetInstance<ICalculator>(); for (var i = 0; i < 10; i++) { Console.WriteLine(calculator.Calculate(10, 5)); Console.ReadLine(); } Console.ReadLine(); } } Assembly "Interface": public interface ICalculator { int Calculate(int a, int b); } Assembly "Implemenation": internal class Calculator : ICalculator { public int Calculate(int a, int b) { return a + b; } } Assembly "Implemenation",

Ninject WCF Extension ArgumentNullException using NET.TCP Binding

允我心安 提交于 2020-02-02 00:30:48
问题 I have a WCF 4 service with 2 endpoints configured to use wsHttpBinding and netTcpBinding. I am hosting the service within IIS 7.5 using WAS and am using the Ninject WCF extension to DI into my service. My service works fine when I use the wsHttpBinding endpoint to call my service but fails when I use the netTcpBinding. When I look in my Application Event Log I get the following error outlined below. I have tried debugging the problem in VS2010 but am getting nowhere fast with this. I don’t

Simple Injector: Injecting a property in a base class

百般思念 提交于 2020-02-01 05:31:25
问题 For several weeks I've been using the Simple Injector dependency injection container, with great success. I love the easy by which I can configure it. But now I have a design that I don't know how to configure. I have a base class where many types from derive, and I want to inject a dependency into a property of the base class, but without having to configure that for every derived class. I tried to do this with attributes, but Simple Injector does not support attributes. Here is a trimmed

Why not use an IoC container to resolve dependencies for entities/business objects?

旧时模样 提交于 2020-01-26 05:15:21
问题 I understand the concept behind DI, but I'm just learning what different IoC containers can do. It seems that most people advocate using IoC containers to wire up stateless services, but what about using them for stateful objects like entities? Whether it's right or wrong, I normally stuff my entities with behavior, even if that behavior requires an outside class. Example: public class Order : IOrder { private string _ShipAddress; private IShipQuoter _ShipQuoter; public Order(IOrderData

Prevent Simple Injector to throw an exception when resolving an unregistered service

旧时模样 提交于 2020-01-22 15:43:05
问题 I was wondering if Simple Injector has an option to stop throwing exceptions whenever GetInstance(Of TService) returns Nothing ? It appears to be throwing them now because I have two requests to get an instance, it's not there, and it throws the exception. Is there a way to prevent the default behavior, a setting somewhere, or something else? 回答1: There absolutely is a simple way of doing this. The SimpleInjector.Container implements System.IServiceProvider, which defines an object GetService