structuremap

Issues with IMutableDependencyResolver and Structuremap in ReactiveUI

。_饼干妹妹 提交于 2019-12-12 01:47:12
问题 First off, let me say that I don't think that is is an issue with ReactiveUI per se, which is why I've not created an issue on its github repo, and second, I realise that I'm using a beta version of ReactiveUI. I want to use Structuremap because I'm going to have a plugin scenario in my WPF app, and the DI container in Splat isn't cut out for that sort of thing. Observe these unit tests: [Fact] public void ShouldBeAbleToOverrideDefaultDependencyResolver() { Locator.Current = new

structuremap Property Injection

爱⌒轻易说出口 提交于 2019-12-12 01:34:25
问题 How to do Dependency Injection on Property of a class Using Structure Map public class ContactController : Controller { public IContactService Service { get; set; } public ContactController() : this(null,null) { } [SetterProperty] public MembershipProvider Provider { get; private set; } } Here when i Create instance of ContactController i want provider to be set to Mock<MembershipProvider> please help me how to go about doing this? Mock is Moq Framework class 回答1: If you are using a Mock, you

Using StructureMap, when a default concrete type is defined in one registry, can it be redefined in another registry?

拈花ヽ惹草 提交于 2019-12-12 01:30:03
问题 In the project I'm working on I have a StructureMap registry for the main web project and another registry for my integration tests. During some of the tests I wire up the web project's registry, so that I can get objects out of the container for testing. In one case I want to be able to replace a default concrete type from the web registry with one in the test registry. Is this possible? How do you do it? 回答1: In a similar situation I created a NestedContainer ( Container.GetNestedContainer(

Set constructor parameter type for structuremap Registry

家住魔仙堡 提交于 2019-12-11 19:59:38
问题 This is the follow up question to thread: How to pass parent/child class as constructor parameter with structuremap? Thanks PHeiberg. Really helps. Got another two questions: Why do we need PricingHandlerFactory constructor there? What it frustrate me is that actually PricingHandler is not invoked directly, we are using reflection and Registry to find PricingHandler. i.e.(Not all codes are pasted.) public class MessageHandlerRegistry : Registry { public MessageHandlerRegistry() { Scan(x => {

Configuring NServiceBus with ASP.NET MVC4 and StructureMap

断了今生、忘了曾经 提交于 2019-12-11 18:39:52
问题 I created an ASP.NET MVC 4 web application by installing structuremap and structuremap.mvc4 from nuget. I then added the nservicebus and nservicebus.structuremap packages, also from from nuget. I've created a couple mvc4 apps with structuremap before with no problems, and I've followed a few tutorials for basic pub/sub with nservicebus and structuremap and got it to work. However, putting nservicebus into mvc4 with structuremap doesn't work very well when I tried. The problem I'm encountering

What is the latest version of structuremap that supports .NET 2.0

泄露秘密 提交于 2019-12-11 16:59:56
问题 I'm working on a project that is stuck on .NET 2.0 (though we can use C# 3.0), and I'd like to use the facilities of a nice container (e.g. StructureMap). Does anyone know what the latest version of StructureMap that supports .NET 2.0 is? Or if there is any other container (preferably not Unity, but I could be convinced) that supports .NET 2.0? Thanks in advance. 回答1: That would be StructureMap-2.0. The next release which is StructureMap.2.4.9 already depends on the System.Core assembly which

How to pass parent/child class as constructor parameter with structuremap?

我与影子孤独终老i 提交于 2019-12-11 16:30:03
问题 Interface: public interface IPricingFactorsRepository { IList<LrfInputRates> GetLeaseRateFactorList( string programCode, string countryCode, string currencyCode, string leaseTerm); } Got below derived/implemented class: public class PricingFactorsRepository : IPricingFactorsRepository { } public class OverridePricingFactorsRepository : PricingFactorsRepository { } Outside, there is such class that accept the interface as constructor parameter: public class PricingHandler { public

Automapper/StructureMap issues with TPL version of synchronous code

試著忘記壹切 提交于 2019-12-11 10:24:44
问题 This is my synchronous working version for some workers to do some different work given a generic workload: foreach (var worker in _workers) { worker.DoWork(workload); } I am trying to exploit existing cores via the task parallel library (TPL) using this: foreach (var worker in _workers) { var worker1 = worker; await Task.Run(() => worker1.DoWork(workload)); } await Task.WhenAll(); The intention is, that each worker is executed in its own thread. Please note that this runs in a async method,

Are StructureMap profiles thread safe?

点点圈 提交于 2019-12-11 07:54:01
问题 I was thinking of using StructureMap's profiles to facilitate offering up slight differences in behavior in my web app based on the authenticated user's type. My question is, if I do something like ObjectFactory.Profile = Session["UserType"]; is it going to be thread-safe or will simultaneous requests potentially interfere with each other when resolving things based on the profile? 回答1: The operations on the static ObjectFactory facade are all "thread safe". This means that you can safely

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily

风流意气都作罢 提交于 2019-12-11 07:00:25
问题 I am Using Entity Framework 4.0 calling the below mentioned code from asp.net. I have a address table in which I need to insert some data. my code is : IRepository<Address> addressRepository; int addressHOCODE = 0; try { **addressRepository = ObjectFactory.GetInstance<IRepository<Address>>();** addressRepository.Add(address); addressRepository.SaveChanges(); addressHOCODE = address.HOCODE; } catch ... At the addressRepository = ObjectFactory.GetInstance<IRepository<Address>>(); line, we're