ioc-container

Interface laravel doesn't bind why?

岁酱吖の 提交于 2019-12-13 19:01:00
问题 Hello guys I was creating a package and i was trying to implement a dependency injection on my class without success. I followed all the instruction for do it work. I'm getting crazy on it. When i try to call Player::team_players(2); it throw me an error: Argument 1 passed to Team\Player\Player::__construct() must be an instance of Team\Player\StatusPlayerInterface, none given, called in C:\wamp\www\ultima\workbench\team\player\src\Team\Player\PlayerServiceProvider.php on line 35 and defined

IOC container working with asp.net mvc 2.0

百般思念 提交于 2019-12-13 16:29:27
问题 Is there any IOC container that already implements a controller factory compatible with asp.net mvc 2.0 ....if so i'll move my projects to 2.0 to test... Anyone know a good reference about it? 回答1: We're using NInject and it works like a charm, too. I compiled it with MVC2 RTM and it works even with that. 回答2: MVCContrib has four different flavors for you ( StructureMap, Windsor, Spring.Net, Unity ) http://github.com/mvccontrib/MvcContrib/tree/mvc2/src/ Here is a direct link to the Unity one:

Get Instance from StructureMap by Type Name

随声附和 提交于 2019-12-13 14:50:51
问题 Is there any way to request an instance from the StructureMap ObjectFactory by the string name of the type? For example, it would be nice to do something like this: var thing = ObjectFactory.GetInstance("Thing"); The use case here is a messaging scenario in which the message is very generic and contains only the name of a task. A handler receives the message, gets the task name from the message and retrieves the type name of the associated task runner from a configuration database.

StructureMap: Creation as Transient (per request) not working

ⅰ亾dé卋堺 提交于 2019-12-13 14:05:15
问题 I'm trying to solve a IoC problem, that seemed easy at first, but turned out to be a pain in the ass:-P I have a heavy weight main class, which must be initialized only once, so it's marked as Singleton. However this class uses a subclass which must be created once for each request, so it's marked as Transient: public class MyRegistry : Registry { public MyRegistry() { For<IMainClass>() .Singleton() .Use(ctx => new MainClass(() => ctx.GetInstance<ISubClass>())); For<ISubClass>() .Transient()

how to write libraries without forcing users to use the library's IOC container

帅比萌擦擦* 提交于 2019-12-13 12:26:21
问题 The short question is: Given a library warrants using a particular IOC container for its internals, when an application consumes that library, given the app warrants using an IOC container for wiring its dependencies, given if the the two containers are different, how can they play well together? The scenario is, the application has classes defined that depend on types from the library. So when the application container attempts to build such a class, it needs to know how to resolve the type

How to register same type twice with different constructors in Unity?

烈酒焚心 提交于 2019-12-13 12:10:27
问题 I'm trying to register the same type but with two different constructors. When I trying to resolve, I get " Resolution of the dependency failed " on the second Resolve. var container = new UnityContainer(); container.RegisterType<IBar, Bar>() .RegisterInstance(new Bar()) .RegisterType<IBar, Bar>() .RegisterInstance(new Bar("foo")); Bar bar1 = (Bar)container.Resolve<IBar>(); Bar bar2 = (Bar)container.Resolve<IBar>("foo"); // ERROR What I'm doing wrong? 回答1: You need to give them names when

IoC container for Caliburn.Micro [closed]

半城伤御伤魂 提交于 2019-12-13 06:21:30
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I will be developing a new WPF application. I decided to use Caliburn.Micro for my MVVM so would like to ask you which one of the known IoC containers is the best approach with WPF Caliburn.Micro framework based on yours opinion or experience ? And if you could say why is

Enterprise Library - Get value from ParameterValue Expression

喜夏-厌秋 提交于 2019-12-13 05:03:32
问题 I am trying to convert Enterprise Library TypeRegistration ConstructorParameters to a collection of key/value pair (a HashTable or an IDictionary in general). The ConstructorParameters property is an IEnumerableOf(ParameterValue) so my problem is how to extract the values from each ParameterValue object. Every ParameterValue object contains a Type and an Expression. For ex. if a ParameterValue contains: "EventLoggingEnabled = false" then I can get the key (which is the EventLoggingEnabled)

Autofac Registering Multiple Containers

梦想的初衷 提交于 2019-12-13 04:34:18
问题 I have a MVC application, and i am using Autofac to resolve dependencies. I have a situation where i have to create 2 containers and runtime should decide which container to use based on a condition. The condition is if the controller Home is called, i need to use container1, or else i have to use container2. Application_Start is the place where I register the container. I am not sure how to make this happen at runtime. Any help is highly appreciated. Thanks 回答1: One reason for letting

MVVM Light - Simple IoC + CommonServiceLocator? Trying to understand the purpose

守給你的承諾、 提交于 2019-12-13 01:24:05
问题 So I am aware that the CommonServiceLocator is an intermediary tie for allowing you to switch out different IoC containers, but looking at the MVVM Light's sample code, specifically the ViewModelLocator, it seems interesting in the sense that You register the SimpleIoC as the default locator, but at the same time you call Register on the SimpleIoc default instance. So if you were going to tear out SimpleIoC in the future, wouldn't it mean you'll need to update all the registration calls?