structuremap

Structuremap 2.6.1 bootstrapper

I'm using StructureMap 2.6.1 This is the code from Bootstrapper.cs: ObjectFactory.Initialize(x => x.For<IFoo>().Use<Foo>()); When I run application, I get the following exception: No Default Instance defined for PluginFamily IFoo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null I don't get an exception when I use t...

Where to put IoC container configuration?

Is it a good practice to create another project in your solution just to configure the container and for registries? I'm wondering where should I put the container configuration, I currently have all the code in my global asax but it's getting messy as I add more registries and more advanced injections. ...

Structuremap Interceptor question

I have been using Structuremap and i have made a an intercepotor to intercept A certain type of Interface to us with events. And when i use the ObjectFactory.WhatDoIHave()); method then the eventhandlers and publishers are all working correct. But when is delete this piece of code then there are no Handlers registered. My interceptor loo...

Use StructureMap with WCF 4.0 REST Services

How do I use StructureMap in a WCF 4.0 REST service? I've used StructureMap in the past using this article but the technique doesn't seem to work with the WebServiceHostFactory(). What's the secret? ...

StructureMap StackOverFlow??? Very Confused

I am building a mvc app using structuremap.. I have quite a few places where I use ObjectFactory.GetInstance(). my app was working fine until I added a couple more functions, now all it does when I start up my app in VWD2010 express is stall and give me a StackOverflowException when I debug. and most of the exceptions are with ObjectFact...

Using ASP.NET MVC 2, StructureMap, Fluent NHibernate, and PostgreSQL

I am using the above combo in a new web app Im doing just to try to learn to build new stuff to expand my knowledge. Im hoping to go live if I do a good job.. Im kind of new at MVC and the other products so I was trying to find a link to a good tutorial that set all of these up together. If anyone knows of one or maybe 2 that set up 3 of...

StructureMap reset singleton instance

Hi there, I have created a bootstrapper which creates a singleton object. Under some circumstances, I wish to have the singleton recreated... I have tried: ObjectFactory.Model.For().EjectAndRemoveAll(); Does anyone know how I can remove current instances for a specific type, without removing the rules that govern its creation. e.g. Ob...

Best practices: Calling GetInstance method to instantiate object

Hello everyone. Lets discuss one thing: I have some simple interface: public interface ICar { void StartEngine(); void StopEngine(); } public interface IRadio { //doesn't matter } and some implementation: public class SportCar : ICar { private IRadio radio; public SportCar(IRadio radioObj) { radio = radioObj; ...

Getting Fluent NHibernate To Build Database tables

I am building an app with ASP.NET MVC2, Fluent NHibernate, StructureMap, and PostgreSQL. I am a total newbie when it comes to Fluent NHibernate. I got a setup going from a couple different sources but when I build and run my app it doesnt create the database tables for the database in my connection string. I have code in a few different ...

Injecting Repository In MembershipProvider.Initialize()? Bad Idea?

I am building an asp.net MVC2 web app using StructureMap. I have created a custom MembershipProvider. I get it properly initialized at startup by calling: x.For<MembershipProvider>().Use(Membership.Provider); x.For<IMembershipProvider>().Use<CPOPMembershipProvider>(); In Initialize(), I am thinking of instantiating a repository to use...

Registering Multiple Mappings of the Same Lookup Type in StructureMap for Constructor Injection

So I have a situation where I want to register n mappings of a particular lookup type. IE: x.For<IWidget>().Add<SquareWidget>(); x.For<IWidget>().Add<YellowWidget>(); And I want to have SM inject an enumerable (Or array) of them into the constructor of a class: public class Machine { public Machine(IEnumerable<IWidget> widgets) {...

Unity to Structuremap help

I am trying to convert this code in my DI mapping from Unity to Structuremap but I cannot seem to get it to work. I am using Repository pattern like the one in found in shrinkr by Kazi Manzur Rashid found here http://shrinkr.codeplex.com/ Any help would be appreciated! Unity Code: .... private static readonly Func<LifetimeManager> per...

StructureMap injected IContainer - where does it come from?

I have an ASP.Net MVC application and I am using StructureMap within MVC to glue the whole application together. There are some model classes that have heavyweight dependencies that are not used in all public methods, so I pass in an IContainer to the model constructor and use that to create the heavyweight dependencies on demand. My qu...

Composition With StructureMap

Looking at a post by Karl Seguin where he show show designing for testability leads to a better design, in this case, composition over inheritance. In the example, his CachedEmployeeLookup has a dependency on an EmployeeLookup, which both implement the same interface, IEmployeeLookup How you would configure this in StructureMap so th...

StructureMap singletons varying by argument?

Using StructureMap, is it possible to have a singleton object for each value of an argument? For example, say I want to maintain a different singleton for each website in a multi-tenancy web app: For<ISiteSettings>().Singleton().Use<SiteSettings>(); I want to maintain a different singleton object corresponding to each site: ObjectFac...

Passing parameters on each wcf call

Hi, I am having this problem. I have integrated structuremap with wcf like it is described here: http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/07/29/integrating-structuremap-with-wcf.aspx the problem is that I am having classes which have constructor parameters like userId and applicationId that I must pass in order structu...

Structuremap resolve tpye with parameters

Hi, I have a problem.... Lest say I have a class like this one: public class A: InterfaceA { private FileInfo _fileInfo = null; public A(FileInfo fileInfo) { this._fileInfo = fileInfo; } ... } and another one: public class B: InterfaceB { private A _classA = null; public B(A classA) { ...

How do I use sturcturemap to pass two different implementations of a single interface into a constructor?

I have a constructor that take two interfaces, they are the same interface, but need to be different implementations: public class Foo { public Foo(IBar publicData, IBar privateData) { } } What I'd like to happen is that structuremap would pass in a concrete implementation of IBar as class PublicData and class PrivateData ...

StructureMap Purge Cached Instances

I'm having trouble resetting StructureMap's configuration. This only fails when I run all my tests en mass. A previous test is Injecting an instance of SingleInvoicePresenter, but by the time I get to this test, I need all caching gone. I would think that ResetDefaults() would clear any previously injected objects out, but this test f...

Decorator Pattern with StrucutreMap (Via Config File)

Hi, A similar question was already answered but with c# code. I would like to know if this is possible with configuration: Here is the question, exactly samething I'm trying to do but with config. http://stackoverflow.com/questions/1443464/structuremap-and-the-decorator-pattern Thanks, Zerdush ...