structuremap

What is the overhead cost associated with IoC containers like StructureMap?

After attending a recent Alt.NET group on IoC I got to thinking about the tools available and how they might work. StructureMap in particular uses both attributes and bootstrapper concepts to map requests for IThing to ConcreteThing. Attributes automatically throw up flags for me that either reflection or IL injection is going on. Doe...

NInject vs. StructureMap etc...

Does anyone have any good suggestions around IoC/DI frameworks? I'm looking into them a bit, but since IoC is new to me I'm looking for pointers on what to check out first. ...

How to pass arguments to a constructor in an IOC-framework

How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) ) object objectToLogFor = xxx; container.Resolve<ILogging>(objectToLogFor); public class MyLogging : ILogging { public MyLogging(object objectToLogFor){} } It seems that this is not possible in Stru...

What's the difference between AddConcreteType and TheDefaultIsConcreteType in StructureMap?

I'm setting up StructureMap and it seems like everything I want to do there are two ways to do it and it's unclear to me what the difference is between them. For instance, what's the difference between these two lines: StructureMapConfiguration.ForRequestedType<IConsumer>().AddConcreteType<Consumer>(); StructureMapConfiguration.ForReq...

StructureMap and SqlCacheDependency

I'm trying to enable SqlCacheDependency through my StructureMap IoC, I'm using LinqToSql I have the code done to take care of the Linq Caching but not quite sure how to go about setting up the SqlCacheDependency as it requires putting this in a global.asa file void Application_Start(object sender, EventArgs e) { string connectionSt...

StructureMap IOC/DI and object creation

I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class uses session object for persistence, and I want use SM to create my basket object through IBasket interface. My basket implementation need HttpSessionStateBase (session state wrapper from mvc) in constructor, which is available inside Controller/Action....

StructureMap error when invalid controller

I am using Structure map like the MVC storefront by Rob Conery does and I have an AdminController and so to get to it I just type: website/Admin/action however if I miss spell the controller name I get the error below: Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: key There error occurs on th...

StructureMap : How to define default constructor by code ?

Hi, I can't figure out how to define the default constructor (when it exists overloads) for a type in StructureMap (version 2.5) by code. I want to get an instance of a service and the container has to inject a Linq2Sql data context instance into it. I wrote this in my 'bootstrapper' method : ForRequestedType<MyDataContext>().TheDefa...

Chaining containers with StructureMap

Is it possible to link containers together in StructureMap like it is in WindsorContainer.AddChildContainer()? I want to achieve having 3 container levels; - 1 page request level - 1 session level - 1 application level These would then be chained together so only one instance request would be made to the "base level" container. The le...

How can I dispose every instance object in StructureMap's ObjectFactory?

I'm using StructureMap in my project and when the application finishes running I need to call the Dispose() method on all of the instances inside the ObjectFactory that implement IDisposable. I cannot find anyway to do it via the StructureMap API. Another thought I had was to get a reference to every instance and call it myself, but I ...

Tell StructureMap to use a specific constructor

I have two services that require an XPathDocument. I want to be able to define named instances of XPathDocumnet to use in the configuration of the two services. I also want to be able to tell StuctureMap which constructor of XPathDocument to use. When I try to get an instance of XPathDocument it tells me that it can't find the plugged ty...

Structuremap : overwrite default configuration for a specific instance

I have following configuration: ObjectFactory.Configure(x=> x.ForRequestedType<IAppDataService>() .TheDefaultIsConcreteType<TestAppDataService>() .AsSingletons()); ObjectFactory.Configure(x=> x.ForRequestedType<IUserDataService>() .CacheBy(InstanceScope.Hybrid)...

How to convert C# StructureMap initialization to VB.NET?

I'm about to put my head thru this sliding glass door. I can't figure out how to execute the following code in VB.NET to save my life. private static void InitStructureMap() { ObjectFactory.Initialize(x => { x.AddRegistry(new DataAccessRegistry())...

Trouble with StructureMap and a public property I need to set

Hi folks, I've got an interface which i've used StructureMap to Dependency Inject. public interface IFileStorageService { void SaveFile(string fileName, byte[] data); } The interface doesn't care WHERE the data is saved. Be it to the memory, a file, a network resource, a satellite in space.... So, i've got two classes that imple...

How to get StructureMap to return a specific instance for a requested type

Hi, I want to register a specific instance of an object for a type in structuremap, how can I do that? For example, When I do: var myObj = ObjectFactory.GetInstance(typeof(MyAbstractClass)); i would like it to return a previously constructed concrete class, which i created like this: var myClass = new MyConcreteClass("bla"); // My...

using (Fluent) NHibernate with StructureMap (or any IoCC)

Hi, On my quest to learn NHibernate I have reached the next hurdle; how should I go about integrating it with StructureMap? Although code examples are very welcome, I'm more interested in the general procedure. What I was planning on doing was... Use Fluent NHibernate to create my class mappings for use in NHibs Configuration Implem...

StructureMap with WCF?

Anyone had any luck integrating StructureMap (DI Framework) with WCF? I can return the default instance in the constructor of my WCF service like this, but obviously it is not ideal. public MemberService() { this.memberRepository = StructureMap.ObjectFactory.GetInstance<IMemberRepository>(); } I have seen this (http://www.lostec...

Determine if StructureMap has a specific type configured?

Is there a way to determine if a specific type has been configured in StructureMap? I want to return a generic type if it has not be specifically configured in StructureMap. ...

Rhino.Commons with StructureMap

Hello there, Has anybody tried to use StructureMap for IoC with Rhino.Commons? Thanks ...

StructureMap - Override constructor arguments for a named instance

Can you override the constructor arguments for a named instance, it seems you can only do it for a default instance. I would like to do: ObjectFactory.With("name").EqualTo("Matt").GetNamedInstance<IActivity>("soccer"); ...