structuremap3

What do I do when ASP.NET 5 (vNext) can't redirect bindings?

亡梦爱人 提交于 2019-12-04 04:00:51
问题 I am just getting my feet wet with MVC 6. I installed VS 2015 and with the default ASP.NET 5 preview MVC Web Application template everything runs fine under local IIS. I then tried to switch out the Default DI container with StructureMap following these instructions exactly (note it is a very recent article). The only thing is I had to figure out the namespaces to import myself (since the author neglected to include them) and this is what I included. I put the StructureMapRegistration class

StructureMap and objects not setup for DI/IoC

为君一笑 提交于 2019-12-02 13:56:57
问题 I have a situation where I've created a factory method to create an object. However, the object has boilerplate code that needs execution before the object is created. Fixing that part of the design is out of scope for this question. Also, when the object is created, a status display is updated on screen. This requires that this status display be instantiated before and be visible and the application be in a running state before creating this object. It is passed to the factory as a

StructureMap and objects not setup for DI/IoC

女生的网名这么多〃 提交于 2019-12-02 06:26:06
I have a situation where I've created a factory method to create an object. However, the object has boilerplate code that needs execution before the object is created. Fixing that part of the design is out of scope for this question. Also, when the object is created, a status display is updated on screen. This requires that this status display be instantiated before and be visible and the application be in a running state before creating this object. It is passed to the factory as a dependency. I'm using v3.1.4.143 of StructureMap. So, here's what I'd be doing in the normal world (pre-IoC):

What do I do when ASP.NET 5 (vNext) can't redirect bindings?

我的梦境 提交于 2019-12-01 18:27:13
I am just getting my feet wet with MVC 6. I installed VS 2015 and with the default ASP.NET 5 preview MVC Web Application template everything runs fine under local IIS. I then tried to switch out the Default DI container with StructureMap following these instructions exactly (note it is a very recent article). The only thing is I had to figure out the namespaces to import myself (since the author neglected to include them) and this is what I included. I put the StructureMapRegistration class and all related classes into a single file, and here are the usings. using Microsoft.Framework

Interception Using StructureMap 3.*

半城伤御伤魂 提交于 2019-12-01 08:58:40
I've done interception using Castle.DynamicProxy and StructureMap 2.6 API but now can't do it using StructureMap 3.0. Could anyone help me find updated documentation or even demo? Everything that I've found seems to be about old versions. e.g. StructureMap.Interceptors.TypeInterceptor interface etc. HAHAA! I f***in did it! Here's how: public class ServiceSingletonConvention : DefaultConventionScanner { public override void Process(Type type, Registry registry) { base.Process(type, registry); if (type.IsInterface || !type.Name.ToLower().EndsWith("service")) return; var pluginType =

Interception Using StructureMap 3.*

泪湿孤枕 提交于 2019-12-01 07:12:13
问题 I've done interception using Castle.DynamicProxy and StructureMap 2.6 API but now can't do it using StructureMap 3.0. Could anyone help me find updated documentation or even demo? Everything that I've found seems to be about old versions. e.g. StructureMap.Interceptors.TypeInterceptor interface etc. 回答1: HAHAA! I f***in did it! Here's how: public class ServiceSingletonConvention : DefaultConventionScanner { public override void Process(Type type, Registry registry) { base.Process(type,

Null User on HttpContext obtained from StructureMap

橙三吉。 提交于 2019-11-27 09:54:09
Ok, my previous question/setup had too many variables, so I'm stripping this down to it's bare bones components. Given the code below using StructureMap3... //IoC setup For<HttpContextBase>().UseSpecial(x => x.ConstructedBy(y => HttpContext.Current != null ? new HttpContextWrapper(HttpContext.Current) : null )); For<ICurrentUser>().Use<CurrentUser>(); //Classes used public class CurrentUser : ICurrentUser { public CurrentUser(HttpContextBase httpContext) { if (httpContext == null) return; if (httpContext.User == null) return; var user = httpContext.User; if (!user.Identity.IsAuthenticated)

Null User on HttpContext obtained from StructureMap

巧了我就是萌 提交于 2019-11-26 14:57:19
问题 Ok, my previous question/setup had too many variables, so I'm stripping this down to it's bare bones components. Given the code below using StructureMap3... //IoC setup For<HttpContextBase>().UseSpecial(x => x.ConstructedBy(y => HttpContext.Current != null ? new HttpContextWrapper(HttpContext.Current) : null )); For<ICurrentUser>().Use<CurrentUser>(); //Classes used public class CurrentUser : ICurrentUser { public CurrentUser(HttpContextBase httpContext) { if (httpContext == null) return; if

Constructor Dependency Injection WebApi Attributes

你说的曾经没有我的故事 提交于 2019-11-26 07:47:32
问题 I have been looking around for a non Parameter injection option for the WebApi attributes. My question is simply whether this is actually possible using Structuremap? I have been googling around but keep coming up with either property injection (which I prefer not to use) or supposed implementations of constructor injection that I have thus far been unable to replicate. My container of choice is Structuremap however any example of this will suffice as I am able to convert it. Anyone ever