Questions tagged [structuremap]

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2.

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2. It can be found at https://structuremap.github.io/.

Installation

StructureMap can most easily be installed through its NuGet package.

Install-Package structuremap

Links

Related

1728 questions
8
votes
3 answers

StructureMap: How can i unit test the registry class?

I have a registry class like this: public class StructureMapRegistry : Registry { public StructureMapRegistry() { For().Singleton().Use(); } I want to test that the…
Marius
  • 9,208
  • 8
  • 50
  • 73
8
votes
1 answer

How do I get StructureMap working with an AngularJs / MVC5 and WebApi2 web project

So I have an AngularJs/MVC project with normal Controllers and decided to move more to an SPA app and add WebApi2 to pass data back to my UI instead of using MVC. In my Global.asax I had the following for my MVC…
sarin
  • 5,227
  • 3
  • 34
  • 63
8
votes
2 answers

StructureMap IRegistrationConvention to register non default naming convention?

I currently have a bunch of repositories like so IMyRepository IAnotherRepository They all inherit from IRepository (if this helps) How can I get structuremap to use an IRegistryConvention scanner to register my concrete types which are…
Scott Mackay
  • 1,194
  • 10
  • 34
8
votes
3 answers

Problem Implementing StructureMap in VB.Net Conversion of SharpArchitecture

I work in a VB.Net environment and have recently been tasked with creating an MVC environment to use as a base to work from. I decided to convert the latest SharpArchitecture release (Q3 2009) into VB, which on the whole has gone fine after a bit of…
8
votes
1 answer

How to register All types of an interface and get instance of them in unity?

How unity can get all instances of an interface and then access them? Code pieces are taken from here : Fail-Tracker In StrcutureMap its possible to register all types of an interface from an assembly and then access them like following: public…
Amir Jalali
  • 3,132
  • 4
  • 33
  • 46
8
votes
7 answers

Influencing AOP with attributes via IoC; code-smell or elegant?

I'm using StructureMap at the moment, generally with convention-based (Scan()) auto-configuration, and I'm looking to add decorator-based caching into the pipeline. If I configure it manually that is fine, but Scan() is just so convenient when you…
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
8
votes
3 answers

Inject AutoMapper

I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle…
Roger
  • 113
  • 2
  • 7
8
votes
2 answers

Best way to use StructureMap to implement Strategy pattern

My web app has some slight variations in business logic and presentation logic depending on the type of user that is logged in. It seems like getting variations by injecting different concrete classes based on the user type is a good fit for DI. So…
JeremyWeir
  • 24,118
  • 10
  • 92
  • 107
8
votes
1 answer

is StructureMap HttpContextScoped necessary?

I saw a code as below in a tutorial of EF code first , MVC and StructureMap to create a Context Per Request pattern: protected void Application_Start() { ... initStructureMap(); } private static void…
8
votes
2 answers

IDbConnection lifecycle management with persistent HTTP connections

I have a problem managing the lifetime of open database connections with StructureMap scoped to HttpContext when there are persistent HTTP connections in my ASP.NET MVC application, like SignalR hubs. My DI container, StructureMap, injects an open…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
8
votes
1 answer

Where's Simple Injector's equivalent of StructureMap's ObjectFactory

I am in the process of migrating from StructureMap to Simple Injector in a ASP.NET MVC3 application. I am using the MVC3 extension for controller DI, but I am running into an issue with trying to replace the static aspects of StructureMap. We have…
Will
  • 311
  • 4
  • 9
7
votes
3 answers

How can I configure Structuremap to auto scan type in Assembly and Cache by Singleton?

I am using mvc.net with StructureMap to scan and register all repositories and services for me. Now I want to register and cache by Singleton. How can I do? IContainer container = new Container(x => { // Register Repositories and…
ensecoz
  • 900
  • 10
  • 16
7
votes
2 answers

StructureMap, NHibernate and multiple databases

I'm working on an Asp.Net MVC 3 application using Fluent NHibernate. I'm just attempting to add an IoC container using StructureMap. I have implemented a custom controller factory which uses StructureMap to create the controller and inject…
TonE
  • 2,975
  • 5
  • 30
  • 50
7
votes
2 answers

Cross Process Mocking in ASP.NET

I'm building a REST API using ASP.NET MVC 3. I'm doing it BDD-style using SpecFlow with NUnit as test runner. Since it's a REST API, testing the Url:s are obviously very important so I want to be able to make real HTTP calls in the specs. I'm now…
ullmark
  • 2,469
  • 1
  • 19
  • 28
7
votes
3 answers

StructureMap InstanceScope.Hybrid and IDisposable

I'm working on an asp.net-mvc application. The linq data context is being passed into my service objects by structure map. I've got is set to have a scope of hybrid. This all works just fine. protected override void configure() { …
Simon Farrow
  • 1,901
  • 2
  • 20
  • 26