ioc-container

Castle Windsor Map Named Component To Specific Property

我的未来我决定 提交于 2019-12-24 05:02:04
问题 Following scenario: We use the Fluent API to register all components in an assembly and two components tyepof(A) with named keys. Another class B with two properties typeof(A) should get the named components injected. Sample: public class A : IA {} public class B : IB { [Named("first")] public IA First { get; set; } [Named("second")] public IA Second { get; set; } } // ... container.Register(Component.For<IA>().Instance(new A(value1)).Named("first")); container.Register(Component.For<IA>()

Constructor on type: “Namespace.type” not found

浪尽此生 提交于 2019-12-24 03:53:23
问题 I am using Castle.Windsor as an IOC. So I am trying to resolve a service type in the constructor of an HTTPHandler. I keep receiving this error, " Constructor on type: "Namespace.type" not found. " My configuration has the following entries for service type: IDocumentDirectory <component id="restricted.content.directory" service="org.myorg.foundations.services.content.IDocumentDirectory, org.myorg.foundations.services" type="org.myorg.foundations.services.content

Binding Generic Types in Ninject 3.0

空扰寡人 提交于 2019-12-24 02:30:35
问题 I want Ninject to create Bindings for all types within a specific assembly that implement a generic interface, without specifying them all at runtime. Kind of like how open generics work in Autofac. This is what i came up with... kernel.Bind(x => x.FromThisAssembly() .SelectAllClasses() .Where(t => t.IsAssignableFrom( typeof(ICommandHandler<>))) .BindAllInterfaces()); Calling the method below, i would expect an array of all types implementing ICommandHandler<T> but it yields nothing... public

Ninject: One interceptor instance per one class instance being intercepted?

陌路散爱 提交于 2019-12-24 00:16:57
问题 I'm currently having a problem, trying to wire up exactly one interceptor instance per one instance of class being intercepted. I'm creating and Advice in the InterceptorRegistrationStrategy and setting the callback to resolve an interceptor from the kernel (it has an injection constructor). Please note that I can only instantiate interceptor in the callback because InterceptorRegistrationStrategy does not have reference to Kernel itself. IAdvice advice = this.AdviceFactory.Create(methodInfo)

ASP.NET Web Api Dependency Injection - Singleton or not

为君一笑 提交于 2019-12-23 17:06:51
问题 I am building a web api with asp.net and i am using the UnityContainer for handling dependencies. For example, my auth controller can depends on the auth service: class AuthController : ApiController { private IAuthService authService; public AuthController (IAuthService AuthService) { this.authService = AuthService; } ... } And the implementation of my auth service can depend on my user repository: class AuthController : IAuthService { private IUserRepository userRepository; public

Good IOC Frameworks to use with asp.net mvc?

霸气de小男生 提交于 2019-12-23 10:11:46
问题 I am wondering what good simple IoC frameworks are there for asp.net mvc? that have good documentation and are just easy to get up and going. Thanks 回答1: I've used Autofac and have been very happy with it. Configuration is mostly done in code so you get compile time checking for your mappings as opposed to programming in XML and hoping for the best. It also supports XML overrides though so if you absolutely need to leave something to be configured at run/deploy time it's possible. The Contrib

Route Model Binding and Soft Deletes - Laravel 4

喜夏-厌秋 提交于 2019-12-23 07:34:52
问题 When using soft deletes and route to model binding their arises a circumstance when you cannot view the injected model if it has been "soft deleted". e.g. I have a Job model. if i "trash" one of these models and then open the trash and try to view the Job model i get a 404 resource not found. I resolved this by using the Route::bind() function as such Route::bind('job', function($id, $route) { return Job::withTrashed()->find($id); }); although this seems unnecessary and a little silly... is

annotation based DI with Producers

杀马特。学长 韩版系。学妹 提交于 2019-12-23 03:32:26
问题 Are there any DI frameworks in the .Net world that is simple and which does not require too much meta-data configuration for eg. using xml etc? A very good example from the Java world would be JBoss Weld. With Weld it is possible to have producer methods (methods that can be marked with custom annotation) that return objects. The objects produced above can be injected where needed. This saves a lot of meta-data configuration. Ofcourse Weld needs an xml too, but it does not mandate extensive

IOC across visual studio projects?

孤街醉人 提交于 2019-12-23 02:48:08
问题 I'm trying to retro-fit (bad idea I know, but better late than never) IOC and DI into an existing solution. The code base is made of up about 30 projects, each which have classes in them which have little or no visibility to the outside world. Being relatively new to the IOC thing I'm trying to use best practise when reworking the code, and it seems best not to pass the IOC container around or make it static, hence I'm trying to do everything via constructor injection. However, and here comes

Load objects with parameters from Laravel IoC container

半腔热情 提交于 2019-12-23 01:54:28
问题 I need a way to load objects via IoC provider depending on a request parameter. Right now I'm loading my objects directly with App::make(xy, [$urlParamter] which I want to refactor, so that I can use dependency injection the way it is supposed to. To describe my current architecture I need to show you quiet some information and in the end you find my concrete questions I have about it. I'm building up a general CMS framework which provides an import architecture that is extendable with a