structuremap

StructureMap Class Chaining - Stack Overflow or other errors

This has completely baffled me on a number of configurations. I keep reading the documentation, and I just don't get it. Here is my registration code: ForRequestedType<SimpleWorkItemProcessor>().TheDefault.Is.OfConcreteType<SimpleWorkItemProcessor>(); ForRequestedType<WorkItemRetryProcessor>().TheDefault.Is.OfConcreteType<WorkItemRetry...

StructureMap and the decorator pattern

I'm using StructureMap, v. 2.5.3 and am having trouble with chaining together implementations on an interface to implement the Decorator pattern. I'm used to Windsor, where it is possible to name variations on interface implementations and send the named impl. into another (default) impl. This is the default, non decorated version, whi...

StructureMap looking for an instance System.Type

I am trying to get an MVC site with NHibernate set up for Dependency Injection using StructureMap. This is a line from my StructureMap Registry: ForRequestedType<NHibernate.ISession>().CacheBy(StructureMap.Attributes.InstanceScope.HttpContext) .TheDefault.Is.ConstructedBy( context => context.GetInstance...

Cannot inject WCF Service dependency in ASP.NET MVC with StructureMap

I have troubles injecting a WCF ServiceClient to a Controller's constructor using StructureMap. I followed Phil Haack's example on DI in ASP.NET MVC The WCF service I have is called LogService. It implements ILogService. The StructureMap.config looks like this: <?xml version="1.0" encoding="utf-8" ?> <StructureMap> <Assembly Name="Ya...

Can Structuremap DefaultConventionScanner find non-public classes

I have just started using StructureMap, having previously worked with Spring.Net. I love the DefaultConventionScanner and the ability to scan assemblies and use convention over configuration to find classes. But there seems to be a limitation that the classes that implement the interfaces must be public, whereas we like to keep out inter...

Are StructureMap profiles thread safe?

I was thinking of using StructureMap's profiles to facilitate offering up slight differences in behavior in my web app based on the authenticated user's type. My question is, if I do something like ObjectFactory.Profile = Session["UserType"]; is it going to be thread-safe or will simultaneous requests potentially interfere with each o...

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 I'm wondering what features of StructureMap I should use to achieve this (or if I'm way of...

Does an abstract class work with StructureMap like an interface does?

I am a big fan of StructureMap and use it in just about everything I do. I have only ever used it with interfaces though. I was wondering if anyone had any experience using with abstract classes? or...does it not support that type of wiring? If you got this to work can you post an example? Thanks! ...

Plugin controllers, StructureMap and ASP.NET MVC

I'm using ASP.NET MVC (1.0) and StructureMap (2.5.3), I'm doing a plugin feature where dll's with controller are to be picked up in a folder. I register the controllers with SM (I am able to pick it up afterwards, so I know it's in there) foreach (string file in path) { var assy = System.Reflection.Assembly.LoadFile(file); Scan(...

Testing the scope of a type with structureMap

How do I test the scope of a registered type with structureMap? For instance I have a registry: public class DataRegistry : Registry { public DataRegistry() { ForRequestedType<ISessionManager>().TheDefaultIsConcreteType<SessionManager>().CacheBy(StructureMap.Attributes.InstanceScope.Singleton); ForRequestedTyp...

Structure map and generics (in XML config)

Hi I'm using the latest StructureMap (2.5.4.264), and I need to define some instances in the xml configuration for StructureMap using generics. However I get the following 103 error: Unhandled Exception: StructureMap.Exceptions.StructureMapConfigurationException: StructureMap configuration failures: Error: 103 Source: Requested Plugi...

Can you do conventions-based binding with StructureMap 2.5.3?

I find one of the best features of Ninject is conventions-based binding. eg. Bind<IConfigurationSource>().To<RemoteConfigurationSource>() .Only(When.Context.Target.Name.BeginsWith("remote")); Bind<IConfigurationSource>().To<LocalConfigurationSource>() .Only(When.Context.Target.Name.BeginsWith("local")); http://ninject.codeplex.com/Wi...

StructureMap 2.5 and internal implementors.

Hi, is it possible to get this stuff working(some way to force Objectfactory create instances like Activator) in the below example everything is placed in a sigle assembly public interface IUnitOfWorkFactory { IUnitOfWork Create(); } internal class NHUnitOfWorkFactory : IUnitOfWorkFactory { public IUnitOfWork Create() { ...

AutoWiring with StructureMap, Constructor Injection...

Hi, I'm new to structuremap. :)) I have a class which implements IPresenter : public class SoldierPresenter : IPresenter { ... public SolierPresenter(ISoldierView soldierView) { } ... } When I call : var presenters = ObjectFactory.GetAllInstances<IPresenter>(); I get zero instances... what am i missing?! Here is the configurati...

Can Dependency Injection delay creating objects required?

Hi folks, I'm playing around with some Dependency Injection (StructureMap) with my ASP.NET MVC application. Works great. Becuase StructureMap is using DI via the most gready constructor (I hope I got that concept named right), I'm under the impression that it creates an instance of an object for each argument, in the most gready constr...

How To Centrally Initialize an IOC Container in MbUnit?

We currently have a suite of integration tests that run via MbUnit test suites. We are in the process of refactoring much of the code to use an IOC framework (StructureMap). I'd like to configure/initialize the container ONCE when the MBUnit test runner fires up, using the same registry code that we use in production. Is there a way o...

With StructureMap is it possible to make a Singleton object AND provide constructor arguments?

Hi folks, I can't seem to figure out how to define a object as a singleton AND define two arguments for the constructor. I can do either / or .. just not at the same time. Eg. (this doesn't work)... ForRequestedType<IFoo>() .TheDefaultIsConcreteType<Foo>() .CacheBy(InstanceScope.Singleton) .WithCtorArg("alpha").EqualToApp...

Structuremap in VB .Net (WebForms)

I'm in the process of trying to hook StructureMap in to an existing webforms application. Since it's webforms I have to use Setter Injection, which is not ideal, but it's better than nothing. Where I'm coming unstuck is translating to VB (I'm really a C# dev currently working in a VB shop). I've written a custom scanner, which works fin...

StructureMap DI on Model Assembly

I’m new to Dependency Injection and had a question/need guidance. I had an application that used the repository pattern for data access. I used StructureMap to get the correct repository and all worked well. I have since broken out my model (including the repository logic) into its own assembly and added a service layer. In the interes...

ValidateInputAttribute not used in custom Controller Factory

I use the following Controller Factory with StructureMap: public class ShopControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(Type controllerType) { if (controllerType == null) throw new HttpException(404, "Controller Not found"); try { return ...