We are a few months into a green-field project to rework the Logic and Business layers of our product. By utilizing MEF (dependency injection) we have achieved high levels of code coverage and I believe that we have a pretty solid product. As we have been working through some of the more complex logic I have found it increasingly difficu...
I'm trying to hock up WCF with dependecy injection. All the examples that I have found is based on the assumptions that you either uses a .svc (ServiceHostFactory) service or uses app.config to configure the container. Other examples is also based on that the container is passed around to the classes.
I would like a solution where the ...
Hello everyone. I'm starting a new project and setting up the base to work on. A few questions have risen and I'll probably be asking quite a few in here, hopefully I'll find some answers.
First step is to handle dependencies for objects. I've decided to go with the dependency injection design pattern, to which I'm somewhat new, to hand...
I have a functional AdjacencyListGraph class that adheres to a defined interface GraphStructure. In order to layer limitations on this (eg. acyclic, non-null, unique vertex data etc.), I can see two possible routes, each making use of the GraphStructure interface:
Create a single class ("ControlledGraph") that has a set of bitflags spe...
I understand basically how IoC frameworks work, however one thing I don't quite get is how code-based config is supposed to work. With XML I understand how you could add a new assembly to a deployed application, then change the config in XML to include it. If the application is already deployed (i.e., compiled in some form) then how can ...
We are building an ASP.NET project, and encapsulating all of our business logic in service classes. Some is in the domain objects, but generally those are rather anemic (due to the ORM we are using, that won't change). To better enable unit testing, we define interfaces for each service and utilize D.I.. E.g. here are a couple of the ...
public class TheController : Controller
{
IThe the;
public TheController( IThe the)
{
//when User.IsInRole("r1") The1 should be injected else r2
this.the = the;
}
}
public class The1 : IThe{}
public class The2 : IThe{}
//anybody knows a good way of doing this ?
...
I'm hitting paralysis by analysis I think...
Which should I go for for my first IOC container: Autofac or Ninject?
(Just want an open source, nice and simple, IOC container)
...
I've been reading about Spring and although it's claimed to be a less complex alternative to EJB, I'm having a hard time wrapping my head around it. Is there a more minimal way of achieving Dependency Injection than adopting the Spring approach?
...
DI creates an extra layer of abstraction so that if your implementation class ever changes you can simply plug in a different class with the same interface.
But why not simply refactor when you want to use a different implementation class? Other languages like Python and Ruby work fine this way. Why not Java?
...
In my project I register many ISerializers implementations with the assembly scanner. FWIW this is the code that registers my ISerializers
Scan(scanner =>
{
scanner.AssemblyContainingType<ISerializer>();
scanner.AddAllTypesOf<ISerializer>().NameBy(type => type.Name);
scanner.WithDefaultConventions();
});
Which then correct...
I'm trying to wrap my head around Dependency Injection.
One of the things I'm confused about is whether all of your object instantiation needs to be controlled by the DI framework (Spring, Guice, etc).
Or, if not, how do you determine which objects are instantiated by the framework and which objects are instantiated with the new oper...
I'm reading a book about DI that always talks about DI frameworks "instantiating an object graph". Why say it this way rather than "instantiating objects"?
...
I code primarily in vb.net. I've been doing basic dependency injection manually and am looking to learn more about DI/IoC and maybe use a DI/IoC framework/container like Ninject. There are lots of examples and write-ups using Java and C# code. I'm looking for the best resources for vb.net programmers. Likewise, is there a particular ...
(This question does not rely on a specific IoC framework, so the interfaces and types in my samples are meta-types. Just replace them with the appropriate types for your favorite IoC framework in your head.)
In my main methods, I typically set up my container doing something like this:
static void Main()
{
IInjector in = new Inject...
I have my business bean defined thus:
@Local
@Interceptors(BusinessInterceptor.class})
public class MyBean implements SomeBean { ... }
And then I want my BusinessInterceptor to be configured with Spring's SpringBeanAutowiringInterceptor:
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class BusinessInterceptor {
@Auto...
If I am writing up a class with more than 1 constructor parameter like:
class A{
public A(Dependency1 d1, Dependency2 d2, ...){}
}
I usually create a "argument holder"-type of class like:
class AArgs{
public Dependency1 d1 { get; private set; }
public Dependency2 d2 { get; private set; }
...
}
and then:
class ...
I'm trying to understand when I should use a container versus manually injecting dependencies. If I have an application that uses a 1-2 interfaces and only has 1-2 concrete implementations for each interface, I would lean towards just handling that myself.
If I have a small application that uses 2-3 interfaces and each interface has ...
I have a class with constructor like this:
public UserRepository(IBlockRepository blockRepos)
{
}
and again, I have another class with the constructor like this:
public BlockRepository(IUserRepository userRepo)
{
}
this causes the Windsor error:
Castle.MicroKernel.Handlers.HandlerException: Can't create component 'UserReposito...
I'm working with MEF right now, but the answer I'm looking for probably is irrelevant to MEF -- it's all dependency injection -- I'm just using MEF terminology as an example here.
Short background story, I read this article over at MSDN with focus on Composite Applications
In this figure there's three things, the shell, the application...