structuremap

What is the difference between HybridHttpOrThreadLocalScoped & HttpContextScoped

Simply, what is the difference between HybridHttpOrThreadLocalScoped & HttpContextScoped? ...

Is there a way to have structmap inject an array of all implementaions of an interface?

Example MyConstruction(IEnumberable<IMyInterface> myInterfaces) { } where I have a couple of classes that implement IMyInterface. ...

Context problem while loading Assemblies via Structuremap

I want to load plugins in a smiliar way as shown here however the loaded assemblies seem not to share the same context. Trying to solve the problem I just build a tiny spike containing two assemblies. One console app and one library. The console app contains the IPlugin interface and has no references to the Plugin dll. I am scanning t...

Using Structuremap to manage ObjectContext Lifetime in ASP.NET MVC

Hi, what I want to know If there is a way or an good article on how to manage the objectcontext life cycle through structuremap (I saw an example with ninject). Since I'm new to the methods and possibilities of SM I really don't know How/If possible to make it. In the first moment I wanted to make a singleton of the objectcontext per htt...

How to get Attribute-Based setter injection in StructureMap?

I'm trying to use setter injection with StructureMap. Yes, I want setter, not constructor injection. I'd like to use it on a custom attribute class, where constructor injection would mess up the [Attribute(constructor params)] syntax. I put together a sample console application to figure out how to do this, but it's not working. What...

structuremap xml configuration override based on machine name

Hi I have the following XML configuration which I would like to set a connectio string based on the machine name of the server i place the code on, but with SM 2.6.1, it doesnt ever seem to apply the LiveSettings profile, can someone tell me what I am doing wrong? <?xml version="1.0" encoding="utf-8" ?> <StructureMap MementoStyle="Attr...

StructureMap dynamic set properties per HttpRequest

StructureMap Configuration Is there a way in SM to dynamically inject property value only for the duration of a request then set the those property back to default after the request is completed? I'm specifically referring in the HttpRequest context. I have a IDBAccessor interface and a DBAccessor concrete implementation. IDBAcces...

Should I use StructureMap or Session to manage a concrete instance?

I am using StructureMap on an ASP.NET MVC project. I have an object that I want to use throughout the session. Should I use StructureMap or Session:["MyObject"] to manage the concrete instance? Thanks in advance. ...

StructureMap to Ninject rules

How to write this StructureMap line in Ninject ForRequestedType<HttpContextBase>() .TheDefault.Is.ConstructedBy(x => new HttpContextWrapper(HttpContext.Current)); ? ...

Injecting a factory method using StructureMap

I'm using a wrapper for the ASP.NET Membership provider so that I can have more loosely coupled usage of the library. I'm wanting to use StructureMap to provide true IoC, but I'm having trouble with configuring it with a User-to-Profile factory object that I'm using to put instantiate the profile in the context of a user. Here's the rel...

StructureMap: How to replace object at runtime

I am trying to inject mocked instance of ISession (NHibernate) to structure map. Currently it all wires it up in a Bootstrap method, but I want to replace the one that is injected with a mocked one. I tried EjectAllInstancesOf but it throw execption. [TestFixtureSetUp] public void TestFixtureSetup() { Bootst...

How do I specify a constructor parameter in StructureMap XML config file?

I wish to specify a concrete type (MyType1) to be instantiated with a specific func passed into the constructor. The constructor is: public MyTYpe1(Func<Type1, Type2> myFunc) { //... } How can I specify the myFunc param in a StructureMap XML configuration file? Note, I wish to pass into myFunc a static method on another type ...

StructureMap error (No Default Instance defined...)

My type accepts 3 decimals as arguments to the constructor, which I am attempting to set in the StructureMap.config XML file (see below). Why do I get the following error? {"StructureMap Exception Code: 202\nNo Default Instance defined for PluginFamily System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyTok...

Team Build sends error when trying to compile a Structuremap method

Hi, I'm getting a strange error when trying to compile a solution that is using StructureMap on Team Build. When I try to compile the solution locally on Visual Studio it works fine, but when trying to queue a new build in Team Build I get the following error: Overload resolution failed because no accessible 'Use' can be called wit...

StructureMap returns a disposed nHibenrate session object from thread local scope

I have this web application which uses SM for IoC. I am using HybridHttpOrThreadLocalScoped scope to store my nHibernate ISession objects. This works ok in a session per request fashion for my web requests. But I also have quartz.net that schedules couple of jobs. The job uses the same unit of work to get the ISession object. In this s...

Simple Factory method using Structuremap

Hello, I'm trying to recreate the following logic using Structuremap.IContainer: public IReplyParams CreateParams(Interface @interface, string response) { switch (@interface) { case Interface.InOtherAssetsReply: return new ReplyNonFinancialAssetsParams(response, infoOrderDataProvider); case Interface...

StructureMap Instance Scope in Web Application

I am initialising the StructureMap DI container at web application start-up with a concrete type for an interface. The concrete type is used to provide a reentrant method to the domain as part of a strategy pattern. How should I decide which InstanceScope to cache by? ...

Structure Map 2.6.1

Hi, In my current project I'm currently trying to replace the Windsor IoC in favour of structure map (2.6.1). But having a bit of problem registering some generic types. How would I register IFilterConverter<T> to use FilterConverter<SomeSpecificType>. I've tried ConnectImplementationsToTypesClosing(IFilterConverter) but from what I've ...

Structuremap, container scope and initialization time

Hi, I have the following constraints: 1) Once the user is authenticated(Not at startup) i use a user property to resolve the configuration required for its execution. this configuration is used to instruct the container how to build some of the services. 2) For each request the container(according to the configuration) needs to i...

StructureMap and named instances

I'm not sure why the following doesn't work. StructureMap tells me there is no default dependency defined for SomeClassWithDependencies...um...dependencies. Can anyone shed any light on this? I want to construct the object through the entire dependency tree based on the named instances. Am I barking up the wrong tree? public class P...