ioc-container

How to configure a logging interceptor for all registered type in Unity?

邮差的信 提交于 2019-12-19 03:11:28
问题 I am going to trace every actions happened in the services which are managed by the Unity Container as logs in file system. I suppose I could define an interface named IService and all the other interfaces or implementation should inherit from him. On the other hand, I would like to develop a custom interception behavior or call handler to save the logs into files. Unfortunately, I found that it doesn't work for me by using this codes IUnityContainer unity = new UnityContainer(); /

Mapper not initialized, When Use ProjectTo()

我们两清 提交于 2019-12-18 19:01:33
问题 I Use Automapper 5.2.0 In My Project. When I Use ProjectTo() In Code Get This Error: Mapper not initialized. Call Initialize with Appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance. Service Code public async Task

Mapper not initialized, When Use ProjectTo()

不问归期 提交于 2019-12-18 19:00:07
问题 I Use Automapper 5.2.0 In My Project. When I Use ProjectTo() In Code Get This Error: Mapper not initialized. Call Initialize with Appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance. Service Code public async Task

Using Unity With Minimal Configuration

我与影子孤独终老i 提交于 2019-12-18 17:03:40
问题 At work, we use Unity a lot. It's great at it's job, but the more you use it, the more your configuration file grows, the more runtime issues increase and the more you have to recreate your unity configuration for each test project. So we end up with a huge unity configuration section that has to be duplicated accross several projects and when it comes time to deploy, you end up having to track down dlls that you forgot to add references to, but you only discover these at runtime. Not fun. I

Unity IOC container and how to resolve different instances of the same interface

你。 提交于 2019-12-18 13:54:04
问题 I have a unity container that I am registering types within like so: IUnityContainer container = new UnityContainer() .RegisterType<ITaxAuthorityRateService, TaxAuthorityPopulationRateService>( "PopulationRate" ) .RegisterType<ITaxAuthorityRateService, TaxAuthorityBusinessLicenseRateService>( "BusinessLicenseRate" ); Then I also want to register 2 different services that take a ITaxAuthorityRateService variable in their constructor. Both services need a different class that derives from

Using Castle Windsor WcfFacility to create client endpoints

 ̄綄美尐妖づ 提交于 2019-12-18 13:25:44
问题 I have created three assemblies. A web site, a WCF service and a contracts assembly that holds the interfaces that the services implement. I would like to use Castle Windsor to create the services for me on the client (website) so that I do not have to have an endpoint in the web.config of the web site for each service that I wish to use. I would like to look at the contract assembly and get all the service interfaces in a namespace. Right now for every service I have something like the

Named Instances and a Default Instance in StructureMap?

老子叫甜甜 提交于 2019-12-18 13:16:05
问题 In my StructureMap bootstrapping code I'm using a custom convention to scan assemblies and add interface/implementation pairs to the object graph as named instances. Essentially I have some logic which checks configuration settings and drills down to this statement depending on various conditions: registry.For(interfaceType).Use(type) .Named(implementationName); This adds all of the named instances well enough. However, I'd also like to add a default instance in the event that an instance

MEF = may experience frustration?

▼魔方 西西 提交于 2019-12-18 12:36:57
问题 UPDATE As I've tried to get MEF working throughout my application, I'm coming across more an more places where I just don't get why it's not automatically creating my library when I expect it to. I think it all comes back to what Reed was saying about needing MEF to create everything. So right now, I have an XML reader class that needs to use my CandySettings, but even though its ICandySettings property has the [Import] attribute, it doesn't get imported. First I found out that [Import] doesn

Silverlight Constructor Injection into View Model + Design Mode

99封情书 提交于 2019-12-18 11:12:19
问题 Im trying to get to grips with writing testable ViewModels in Silverlight 4. Im currently using MVVM light. Im using AutoFac and the IoCContainer is doing its job fine. However to inject into the constructor of ViewModels, which are bound to Views I have this constructor chaining: public UserViewModel() : this(IoCContainer.Resolve<IUserServiceAsync>()) { } public UserViewModel(IUserServiceAsync userService) { if (this.IsInDesignMode) return; _userService = userService; } Which doesn't feel

Laravel: Difference App::bind and App::singleton

自古美人都是妖i 提交于 2019-12-18 10:26:19
问题 I get a bit confused over all the nice things laravel has to offer in terms of the IOC container and facades. Since I'm not an experienced programmer it gets overwhelming to learn. I was wondering, what is the difference between these two examples: A facade to 'Foo' and registered in the container via App::bind() A facade to 'Foo' and registered in the container via App::singleton() In my best understanding Foo::method() will be rewritten as $app->make['foo']->method() so in the first example