structuremap

MVC 2.0, StructureMap, Areas, and Duplicate Controller Names

I have a bit of a problem. I have an area called Framed. This area has a home controller. The default for the site also has a home controller. What I'm trying to do with this is have a version of each controller/action that is suitable for an IFrame, and a version that is the normal site. I do this through Master pages, and the si...

Structure Map Profiles and Adding Instances

Structure map (2.6). I have some classes and a registry that look like the following: public interface IManyType {} public class ManyType1 : IManyType {} public class ManyType2 : IManyType {} public class ManyType3 : IManyType {} public class TestRegistry : Registry { public TestRegistry() { For<IManyTy...

StructureMap get requested type

Is it possible to pass the requesting type as a parameter when configuring a StructureMap container. For example: container.Configure(x => { x.For<ILogger>().Use(new TestLogger(log.Add, requestingType)); }); Where requesting type is the consuming object's type: public class SomeClass ...

How to perform conditional binding in StructureMap from within a registry and without the use of generics?

I am familiar with Ninject and in Ninject you can do something similar to Bind<ICalendar>().To<MonthCalendar>().WhenInjectedInto(typeof(Roster)).InRequestScope(); I'm not sure how to perform something similar in StructureMap. I need to be able to do this dynamically from my own binding without the use of the generic StructureMap metho...

structuremap Property Injection

How to do Dependency Injection on Property of a class Using Structure Map public class ContactController : Controller { public IContactService Service { get; set; } public ContactController() : this(null,null) { } [SetterProperty] public MembershipProvider Provider { get; private set; } } Here when i ...

Questions about StructureMap in a (layered) library regarding extendability and testability

Hi, We are using StructureMap as our Dependency Injection (DI) framework while we are creating a layered library. Our goals are to: Make it easy for us to Unit Test classes (and using mock classes instead of the real dependencies) while we develop and maintain the library. Make it easy for the library user to: Customize the library b...

StructureMap Conditional use

I hawe all day strugle my head and i canot find any solution to my case so i nead help. Hear is my problem: I hawe two classes that implement one interface public interface ICacheObject { string Get(); } public class WebCacheObject : ICacheObject { public string Get() { return "Web"; } } public class SysteCach...

Using structuremap to Register Generic Types

Hello All, I am new to structuremap. I am trying to get Structuremap to auto-register public void RegisterAllEventHandlers() { Scan(cfg => { cfg.TheCallingAssembly(); //cfg.IncludeNamespaceContainingType<NewCustomerCreated>(); cfg.IncludeNamespace("ParentNameSpace"); cfg.AddAl...

Doing interception with structuremap

I'm trying to do some attribute-based interception using structuremap but I'm struggling to tie up the last loose ends. I have a custom Registry that scans my assemblies and in this Registry I have defined the following ITypeInterceptor whose purpose it is to match types decorated with the given attribute and then apply the interceptor ...

Struturemap in static context

I'm using a custom route in my mvc application that inherits from RouteBase. In my global.asax I register the route like this: routes.MapPageRoute("PageRoute", ObjectFactory.GetInstance<IRepository>()); In the GetRouteData method I use my repository to fetch the correct page and then I put that in the RouteValueDictionary like this: ...

Calling Method of a Class within StructureMap Registry Configuration

I can't help but think there is a better way to do this than my current code within my StructureMap Registry. For<ISchedulerFactory>().Use(() => new StdSchedulerFactory()); For<IScheduler>().Use(() => new StdSchedulerFactory().GetScheduler()); Is there a way to have it use the previous registered type and call the method from that...

Ninject to StructureMap

I am looking to convert following code to StructureMap: private Mock<MembershipProvider> MockMembership = new Mock<MembershipProvider>(); private StandardKernel GetIoCKernel() { var modules = new IModule[] { new InlineModule( new Action<InlineModule>[] { m => m.Bind<MembershipPro...

Using structuremap how do I resolve a type when I only have a string from the type name

Hi I have a requirement to use a plug in model where I need to allow types of ITask to be created by structuremap but where I only have a string of the type name at runtime. These types need to use Ctor injection to be composed, so I can't build up an existing type. Also, I don't want to get all types and then query the type name as th...

StructureMap - How to register and resolve an open generic type

public interface IRepository<T> where T : Entity { void Delete(T entity); T[] GetAll(); T GetById(int id); void SaveOrUpdate(T enity); void Merge(T entity); } public interface ITeamEmployeeRepository : IRepository<TeamEmployee> { PagedList<TeamEmployee> GetPagedTeamEmployees(int pageIndex, int pageSize); } publ...