structuremap

How can I get an instance in StructureMap Registy constructor?

How can I get an instance of some type (registered in a different Registry) inside StructureMap Registy constructor? I want to use such a code: public RepositoriesRegistry() { IApplicationSettings lApplicationSettings = ObjectFactory.GetInstance<IApplicationSettings>(); Debug.Assert(lApplicationSettin...

How to setup named instances using StructureMap profiles?

I've done quite a bit of googling and searching here on SO, but couldn't find a similar question or answer. In typical SM configuration you can add multiple named instances for a single PluginType: ForRequestedType<IFoo>() .AddInstances( x => { x.OfConcreteType<FooA>().WithName( "FooA" ); x.OfConcreteType<FooB>().WithName...

StructureMap, LinqToSql, testing best practise

This is my first project using StructureMap, it is an MVC web app and I'm using LinqToSql for my dataaccess. I'm following the repository pattern so a large amount of testing will avoid the db. However, for my CRUD operations I'm going to have the DataContext create a new db for each test. My domain model is being held in its own assemb...

Injecting ISession Into My Repositories Using Structuremap in a Asp.Net MVC Application

My repositories all take ISession in the constructor: protected Repository(ISession session) { this.session = session; } private readonly ISession session; In an Asp.Net MVC application, using StructureMap, how would I go about setting up ISession in my the StructureMap Registry? Would I need to to add SessionFactory to the conta...

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 = ObjectFactory.GetAllInstances<IValidator<Person>>(); var AddressValidators = ObjectFactory.GetAllInstances<IValidator<Address>>(); I know how...

Structure Map Generic Type Scanner

High Level With StructureMap, Can I define a assembly scan rule that for an interface IRequestService<T> will return the object named TRequestService Examples: FooRequestService is injected when IRequestService<FooRequest> is requested BarRequestService is injected when IRequestService<BarRequest> is requested Details I have a gen...

Add intellisense documentation to StructureMap

By default all I get in intellisense are the functions and its signature. I would prefer if I could also get documentation with the intellisense. I realise that I am supposed to place an xml file that contains this documentation along with my dll. From where can I get this is file? Or is there some other way for me to achieve this? ...

StructureMap AlwaysUnique does not seem to work with constructor injection

Hello, I have this configuration in my GeneralRegistry: ForRequestedType<IClientBonusHistoryLoadTask>().AlwaysUnique().TheDefaultIsConcreteType<ClientBonusHistoryLoadTask>(); And I have this code: public ClientAdvantagesUpdateTask(IBaseRepo<Client> repository, INHUnitOfWorkProvider uowProvider, IClientBonusHistoryLoadTask clientBonu...

is working with IContainers a better idea that ObjectFactory directly (structuremap)?

specifically, will working with containers as opposed to the static ObjectFactory let me keep multiple concurrent configurations, or are containers singletons? ...

StructureMap Open Generics and CacheBy Singleton

I have a number of repositories that inherit from a base class Repository. Currently I am registering in-memory implmentations with Structure map like this (and it's working great): ForRequestedType<Repository<Timeslot>>() .TheDefaultIsConcreteType<InMemoryRepository<Timeslot>>() .AsSingletons(); ForRequestedType<Repository<Ap...

StructureMap Exception Code: 208

Hi guys, Im getting Requested type x is not configured in StructureMap. I have created a windows service in which i want dependency injection. I have added the reference to that windows service. And also added the structuremap file to the windows service and also added the assembly inside structuremap.config file. But still im getting th...

Structure Map Registry DSL Override

Is there an equivalent xml configuration for StructureMap's Registry DSL configuration: ForRequestedType<T>().TheDefaultIsConcreteType<T>(); There is some limited documentation around Structure Map's XML Configuration on the SM site, but I have yet to get any XML configuration items to override Registry DSL entries. Is there a way ...

Using interfaces with Linq-to-Sql for decoupling

I am re-factoring a model class into an interface. The model class is auto-generated with Linq-to-Sql. class FooRepository { // ... public void Add(IFoo foo) { db.Foos.InsertOnSubmit(foo); } } The InsertOnSubmit method takes an instance of Foo, not an IFoo. I can cast the instance inline to (Foo) and th...

StructureMap automatically register descendant classes

I have a base class of Repository<T>. In a particular project I have several implemetations of this base class. e.g. PersonRepository : Repository<T> EmployerRepository : Repository<T> Right now, I am register each of these repositories in a StructureMap ServiceRegistry class. like this: ForRequestedType<Repository<Person>>() .T...

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 error: Test.Web.Controllers.StructureMapControllerFactory.GetControllerInstance(System.Type)': no suitable method found to override C:\...

how can i use structure map asp.net 3.5

I am new to the structure map but i want to use it in my asp.net site for dependency injection can any one suggest me simple example to use structure map for the dependency injection ...

Very Basic StructureMap ?

Ok, I wrote this question up earlier today but I decided to delete it because I thought the question wasn't worded very well. I decided to wait until I had more time to compose it at home :). I am just getting started with IOC/DI. I have done some research on which framework to use and decided to give StructureMap a spin. The following i...

which one is better structure map or unity application block

I want to use dependancy injection technique in my site. For that i want to choose either structuremap or unity application block. So which one is better and why we should use one of them? ...

Selecting all items in a profile structuremap

I am using structure map and setting up a service based on the profile string passed. I have a list of objects. List of IProcessors that I need to inject to the RecognizerSaga to process against each of these processors. Say, bootstrapping code looks something like this: x.CreateProfile("A1", p => { p.Type<IProcessor>().Is.OfCo...

Structuremap, consturctor that takes a list of plugins.

I got an interface like this public interface IWriter { ... } and a class public class WriterMerger { public WriterMerger(IEnumerable<IWriter> writers) ... } I want structuremap to fill out the constructor argument on WriterMerger with all registered IWriter's. I registered the different writers with StructureMap.ObjectFact...