structuremap

StructureMap Exception Code 205 Missing requested Instance property

Hi there. I'm trying out the latest build of StructureMap, to learn about IoC containers and the like. As my first test, I have the following class: public class Hospital { private Person Person { get; set; } private int Level { get; set; } public Hospital(Person employee, int level) { P...

Choosing which constructor to use with StructureMap

I know that I can specify a constructor to use with the DefaultConstructor attribute. However, I also want to be able to use a different constructor in some instances. Is there any way I can register both constructors with StructureMap, and then choose which one to use when I call ObjectFactory.GetInstance()? ...

StructureMap: Configure concrete classes at run time?

I know that Concrete Types can be configured with Structure Map the following way: ForRequestedType<Rule>().TheDefault.Is.Object(new ColorRule("Green")); This works if you know the type ahead of time. I want to do it at run time, and there does not seem to be a way. Can some one enlighten me? What I want to do is something like the...

[StructureMap] 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 instances are hardcoded in the dll. So, practically, its as good as having hard coded the depend...

StructureMap exception: No Default Instance defined for PluginFamily

I have a SysMsgManager class defined in CoreService project as following: public class SysMsgManager { private ISysMsgRepository _SysMsgRepository; public SysMsgManager() { _SysMsgRepository = ObjectFactory.GetInstance<ISysMsgRepository>(); } .... } In my DataAccess project I have 'ISysMsgRepository' int...

Inject Multiple MembershipProviders with Structuremap

I have an existing ASP.NET MVC application and am using StructureMap as my IOC container of choice. Currently when a controller needs an IMembershipProvider I use StructureMap to inject a concrete instance in the controller's constructor based on the BuyerMembershipProvider configuration from my web.config file as in the below solution c...

entlib 5 and structuremap

I am trying to configure entlib 5 with a structuremap. All examples are mostly based on Unity Container, can you point me to the link / example for structuremap and entlib 5 configuration? ...

IOC best practice: How to best manage dependency graph?

I am doing an MVC project with structuremap as an IOC container. We are doing TDD, and I want to set up my dependencies so that its easy to work with, and so that its easy to test. How should I best set up the graph of dependencies for the below fictional illustrated graph ? ApplicationController Controller AuthenticationService Us...

StructureMap - Instantiating properties for instance of interface x on concrete request

Hi! How do I wire structuremap to inject properties when builing instances of interface IDummy. Let's say that I have a concrete class called Dummy which implements interface IDummy. The Dummy class got two properties, the first one called DataContext implements IDataContext, the second property is just a basic string called MyDummySt...

Multiple constructor with Structuremap changing the scope?

To illustrate the problem, here is a simplified version of my setup. I have a factory like this one : public interface IFactory{ } public class Factory : IFactory { public Factory() { Console.WriteLine("parameterless"); } //public Factory(int i) //{ // Console.WriteLine("with parameter : {0}", i); ...

How to write a StructureMap Scanner for this case

I have these registrations in a registry and am trying to figure out the correct way to implement them with a scanner instead of manual registration. For<ISomeView>.Use(HttpContext.Current.CurrentHandler) For<IOtherView>.Use(HttpContext.Current.CurrentHandler) For<IAnotherView>.Use(HttpContext.Current.CurrentHandler) And so on. I have...

Dependency injection - am I missing something?

Hi, I am using structuremap in an asp.net (mvc) project and I am fairly happy with the functionality. One thing just came to me where I am not sure if I am too blind to see. I get several services instantiated in my controller class by structure map, but I want them to share methods that are base (hint) to all services. How can I achiev...

Problem Implementing StructureMap in VB.Net Conversion of SharpArchitecture

I work in a VB.Net environment and have recently been tasked with creating an MVC environment to use as a base to work from. I decided to convert the latest SharpArchitecture release (Q3 2009) into VB, which on the whole has gone fine after a bit of hair pulling. I came across a problem with Castle Windsor where my custom repository inte...

Passing the ModelState of a constructor to its Service using StructureMap

I've this controller public class AdminController : Controller { private IAdministratorService _administratorService; public AdminController(IAdministratorService administratorService) { _administratorService = administratorService; } } And I've this: private ModelStateDictionary _modelState; public AdministratorService(IRe...

Structuremap searching for scripts controller every page

I've configured structuremap successfully but every page search for a controller with name "scripts" public class StructureMapControllerFactory : DefaultControllerFactory { public override IController CreateController(RequestContext context, string controllerName) { Type controllerType = base.GetControll...

Problem with StructureMap/nhibernate setup:

Hi I keep getting the following error: Cannot access a disposed object. Object name: 'AdoTransaction'. The setup follows the example given at http://trason.net/journal/2009/10/7/bootstrapping-nhibernate-with-structuremap.html here is the IUnitOfWork class (exactly the same as the one in the link): public class UnitOfWork : IUnitOf...

Inject an empty string via Structuremap xml config

When I use the following in a structuremap xml config file, it is like I didn't specify the captureFileName parameter at all. How can I inject an empty string? ...

asp mvc 2 structure map not working when deployed.

I'm using structure map in my asp mvc site, which i've just tried to deploy onto II6 for the first time. The basic dependency structure is very typical: public ControlMController(IControlMService controlMservice) { this._controlMservice = controlMservice; } ... public ControlMService(IControlMRepository re...

StructureMap singleton usage (A class implementing two interface)

public interface IInterface1 { } public interface IInterface2 { } public class MyClass : IInterface1, IInterface2 { } ... ObjectFactory.Initialize(x => { x.For<IInterface1>().Singleton().Use<MyClass>(); x.For<IInterface2>().Singleton().Use<MyClass>(); }); var x = ObjectFactory.GetInstance<IInterface1>(); var y = ObjectFactor...

StructureMap Plugins, calling init method when registered

Hi, I am exploring the possibility of using StructureMap to load all instances of my plugin type IPlugin from a specific directory using the Scan feature. When a plugin is registered with StructureMap I would like to call an Init method that would register the plugin in the database if it was the first time it had been seen. Is there ...