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...
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...
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...
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...
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...
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...
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...
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!
...
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(...
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...
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...
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...
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()
{
...
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...
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...
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...
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...
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...
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...
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 ...