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
10
votes
3 answers

Action Filter Dependency Injection in ASP.NET MVC 3 RC2 with StructureMap

I've been playing with the DI support in ASP.NET MVC RC2. I have implemented session per request for NHibernate and need to inject ISession into my "Unit of work" action filter. If I reference the StructureMap container directly…
Ben Foster
  • 34,340
  • 40
  • 176
  • 285
10
votes
1 answer

Simple but good example on how to use Dapper with Structuremap and dependency injection

I am trying to understand how to use Dependency Injection with Dapper (IDbConnection) and still being able to use built in dispose. I have found a couple of articles on the web but non that I think is easy to understand. What I am trying to figure…
Henrik Fransas
  • 1,067
  • 1
  • 10
  • 16
10
votes
2 answers

Xml configuration or Configuration through code?

I personally like the option to configure StructureMap from C# code. From what I understand, one of the advantages of DI, is that we can easily swap in a new concrete instance. But, if the configuration is defined in code, then the concrete…
Amith George
  • 5,806
  • 2
  • 35
  • 53
10
votes
2 answers

Using StructureMap with unit tests

I'm using StructureMap in a web project for DI IOC. It works perfect, but I don't have a clue how to write unit tests with StructureMap. Should I do this in AssemblyInitialize start Configuration of StructureMap like in global.asax except for…
Florim Maxhuni
  • 1,421
  • 1
  • 17
  • 35
10
votes
3 answers

Using structuremap with log4net wrapper

I have the following interface: public interface ILogger { void Debug(string message, params object[] values); void Info(string message, params object[] values); void Warn(string message, params object[] values); …
Chris
  • 27,596
  • 25
  • 124
  • 225
10
votes
3 answers

ASP.NET MVC 2 Preview 1 - Problem compiling StructureMap Controller Factory

I have a project for which I use StructureMap for dependency injection. The project compiles fine as a MVC project but after moving everything to a MVC2 project I am now receiving the following…
gun_shy
  • 485
  • 2
  • 7
  • 17
10
votes
1 answer

Can I use StructureMap to return all implementations of a generic interface for a specific type parameter

I have a generic interface, IValidator. I want to be able to use StructureMap to retrieve a list of all classes that implement IValidator for a given type T. For example, var PersonValidators =…
Mark Capaldi
  • 405
  • 1
  • 5
  • 10
10
votes
1 answer

asp.net MVC 4 with StructureMap

I am converting an ASP.NET MVC3 project to MVC4. I was trying to find the best approach to work with StructureMap and MVC4. I've found a couple of solution which might work, but haven't tried them yet. The first solution is very simple and…
LeftyX
  • 35,328
  • 21
  • 132
  • 193
9
votes
1 answer

Which PreApplicationStartMethod should I use?

I noticed that when I installed StructureMap from NuGet into my ASP.NET MVC3 project, Dave Ebbo's WebActivator package was also added as a dependency. WebActivator provides a PreApplicationStartMethod attribute and, in the boilerplate code added at…
Kev
  • 118,037
  • 53
  • 300
  • 385
9
votes
3 answers

NHibernate: How to inject dependency on an entity

NHibernate 3.2/Fluent NHibernate 1.3/StructureMap 2.6.3 - Trying to follow DDD as an architectural strategy, I typically don't have dependencies on domain entities. However, I'm experimenting right now with adding more behavior to my domain entities…
Byron Sommardahl
  • 12,743
  • 15
  • 74
  • 131
9
votes
1 answer

How to release HybridHttpOrThreadLocalScoped objects in StructureMap?

When performing background tasks in a Windows Service I used HybridHttpOrThreadLocalScoped for storing intances of NHibernate ISessions. Since within a Windows Server there isn't a HTTPContext, I'm wondering if only calling the…
Roman
  • 10,309
  • 17
  • 66
  • 101
9
votes
2 answers

Inject service into an AutoMapper destination class

Say I have a source and destination class that is mapped using AutoMapper. The destination has a logger service injected into the constructor. However, I don't know how to get the service injected into the constructor through StructureMap? I've…
jaffa
  • 26,770
  • 50
  • 178
  • 289
9
votes
1 answer

StructureMap proxy all instances or modify instances just before returning

In StructureMap we can proxy TInterface and TConcreteImpl with TProxy this this: ConfigurationExpression config = ... config.For().DecorateAllWith(); config.For().Use(); I wanted to use DispatchProxy…
Node.JS
  • 1,042
  • 6
  • 44
  • 114
9
votes
1 answer

StructureMap get registered types, not instances

I have a plugin system that allows a user to choose the type of plugin they wish to create (basically this sets up a configuration for a plugin instance). They choose the plugin type from a select list. I am using StructureMap to inject an…
Ben Foster
  • 34,340
  • 40
  • 176
  • 285
9
votes
3 answers

StructureMap Auto registration for generic types using Scan

I've got an interface: IRepository where T : IEntity while im knocking up my UI im using some fake repository implementations that just return any old data. They look like this: public class FakeClientRepository : IRepository At the…
Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231