structuremap

Structuremap Generics with two type parameters

Hi, I know I can, in Structuremap, do this: var container = new Container(cfg => { cfg.For(typeof (IDomainDataRepository<>)).Use(typeof (DomainDataRepository<>)); }); but what if my Interface has 2 type parameters: IDomainDataRepository<T,TKey> instead ofIDomainDataRepository<T> How to tell Structuremap to instantiate this type ...

Type not being instantiated correctly by StructureMap (using XML configuration)

OK, I'm stumped over a seemingly trivial piece of functionality. How can I get StructureMap to initialize the properties on type instances retrieved from the container, using XML configuration (unfortunately I have to use XML)? My current code is: The type and interface: public interface IMyType { decimal MyProperty { get; set; } }...

Why is BaseController's overloaded constructor not being executed?

I have a base controller which is defined as follows, but the constructor that takes the ISiteService never gets executed: public class BaseController : Controller { private ISiteService _siteService; public BaseController() {} public BaseController(ISiteService siteService) { _siteService = siteService; // thi...

For(typeof(IRepository<>)) in C# to vb ?

I've got a method I'm trying to translate from c# to vb, goes something like this .. x.For(typeof(IRepository<>)).Use(typeof(Repository<>)); VB doesn't seem to like the idea of a IRepository(Of ) ... what's the syntax on that? ...

StructureMap, NHibernate and ASP.NET MVC fails to lazy load

I'm urrently working on a MVC project based on StructureMap and NHibernate. It's my first time using StructureMap, so I might be using it wrong, which causes these troubles for me. In my Application_Start I initialize StructureMap like this: ObjectFactory.Initialize(x => { x.For<ISessionFactory>() .Singl...

Structuremap and references, what is best practices?

I am trying to use structure map for the first time. I have used ioc containers before, but always with xml config. As structure map uses config through code (I know it can be done in xml as well, but most examples are using the config through code) I am running into some issues with references. Let's work with the following example (no...

Is it possible to name a dependency with StructureMap?

I would like to be able to inject named dependencies into a class using StructureMap if that is at all possible. The main reason I want this right now is for connection string injection. I may be doing this the wrong way, but here's how I've got it (just need to add injection now): psuedo: public class MyServiceClass string conne...

profiles in structuremap

Hi, I have common setup and setup specific to request context(example for specific locality). I was suggested to use profiles and on runtime work through a factory which would fetch the specific details from the context of the request and by convention load a profile to a nested container. I can set profiles with names by convention bu...

Structuremap does not load registries when started from Network drive

Hello, I am an enthousiastic (new) user of structuremap but I am experiencing a problem loading registries. When I start my application from a local drive all the registries in my application are used to resolve types. I verified this by ObjectFactory.WhatDoIHave() However when I start the same application from a share then not all re...

StructureMap 2.6.1.0 Assembly scanning problem

I am trying to use StructureMap to scan at runtime for assemblies that contain an implementation of the Registry class, but I'm running into a problem. If a dll contains a Registry class, but also contains a reference to a dll that isn't present at runtime (say a Rhino.Mocks dll that isn't required at runtime), StructureMap will throw ...

Wire up StructureMap with generic open type arguments

How would I wire up StructureMap with the following: public Interface IRepository<T, TIdentity>{} public abstract class Repository<T, TIdentity> : IRepository<T, TIdentity>, other interfaces I have many concrete implementations of Repository and need StructureMap to wire them up automatically. public class JournalRepository : Reposit...

How can I get StructureMap's AutoMocker to mock fake data?

I'm currently trying to implement StructureMap's AutoMocking functionality and I need help with getting the mocked . I have a Test method as follows: [Test] public void DirctoryResult_Returns_Groups() { var autoMocker = new RhinoAutoMocker<GroupController>(MockMode.AAA); GroupController controller = autoMocker.ClassUnderTest; ...

NHibernate constructor injection

I have a domain type, MyDomainType, mapped to a db table using NHibernate. I'd like an instance of MyInjectedType to be injected into the constructor of MyDomainType when each instance is initialised by NHibernate, so that the injected type instance is ready and available for use within MyDomainType instances retrieved from the database....

IoC Container Hurdle for ASP.Net MVC Newb

Hi, I must admit that I'm new to ASP.Net MVC and I'm currently researching all the best practices on how to start my new project. So far I have understood the concepts of the Repository Pattern and Unit of Work and I have gone onto Dependency Injection and Inversion of Control (IoC). I have been looking into this for the last 2 days an...

StructureMap profiles and web requests question

I want to have several different versions of my software based on a parameter passed in on the request. I'm currently trying to accomplish this with profiles. What I need to know is, if I have something like (pseudo) ObjectFactory.Profile = Request.Params["version"]; var instance = ObjectFactory.GetInstance(...); is it possible for ...

Structuremap and Unit Testing - Inject stub for ObjectFactory.GetNamedInstance

Hello, I am writing some unit tests for an MVC controller which requires a call to ObjectFactory.GetNamedInstance. The code looks as follows ObjectFactory.GetNamedInstance("BuyerMembershipProvider") I am aware of the ObjectFactory.inject method to Inject a stub of the desired type, however it does not seem to work for getnamedinsta...

StructureMap: How to use more than one concrete Class per Interface

How can I figure StructureMap to use more than one concrete Class per Interface. i.e. an IRepositoryCustomer is implemented by: RepositoryCustomerA and RepositoryCustomerB How do I register and resolve this to/from the StructureMap IoC container? ...

Structuremap - Caching a single object instance for all request

Hi, if I want StructureMap to return a single object instance for all requests, is there any difference at all between the two methods below?? StructureMap.ObjectFactory.Initialize(x => {x .ForRequestedType<ISplitPaymentConfigurationReader>() .TheDefaultIsConcreteType<SplitPaymentConfigurationReader>() .CacheBy(StructureMap.Att...

structuremap objectfactory life time

Hi, i've been using structuremap since a couple of months. I always use ObjectFactory.GetInstance to take the right instance of the object i've to use. Actually, i need to understand which is the default ObjectFactory's InstanceScope. Is it ThreadLocal? do u know where i can read about it? ...

Why are some references missed when running my application?

I have the following project structure using a Domain Model, StructureMap and Fluent NHibernate: The problem I'm having is that Fluent NHibernate requires all of the following to be the bin directory of the website for it to work at runtime: Antlr3.Runtime.dll * Castle.Core.dll Castle.DynamicProxy2.dll FluentNHibernate.dl...