I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern.
I'm looking at autofac for my IoC container, but I don't think that matters too much for this disucssion.
Injecting a service into the start window seems straightforward, as I can...
Have you found Guice useful to manage DI in you applications or run stress tests or even brought an application using Guice to a production phase in your company?
If you have, have you run into any issues with it?
...
Hi folks,
what's the best practice for creating test persistence layers when doing an ASP.NET site (eg. ASP.NET MVC site)?
Many examples I've seen use Moq (or another mocking framework) in the unit test project, but I want to, like .. moq out my persistence layer so that my website shows data and stuff, but it's not coming from a datab...
Can anyone think of a good solution for getting IOC into a console application?
At the moment we are just using a static class with the following method:
public static T Resolve<T>()
{
return dependencyResolver.Resolve<T>();
}
I would like the experience to be seamless but cannot think of a way of achieving this from a console ap...
Let's say we have
public interface ITimestampProvider
{
DateTime GetTimestamp();
}
and a class which consumes it
public class Timestamped
{
private ITimestampProvider _timestampProvider
public Timestamped(ITimestampProvider timestampProvider)
{
// arg null check
_timestampProvider = timestampProvider...
I've done quite a bit of searching on this and haven't had much luck finding something cohesive. I'm a relatively new developer and have just started in my first professional development position. I know that I have a great deal to learn even in the realm of the basics. Based on listening to PodCasts, reading blogs, papers etc; I've c...
I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.
I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for EmployeePresenter) are...
OK so I'm looking a some code which looks roughly like this:
void DoSomething(object o)
{
if (o is Sometype1) {
//cast o to Sometype and do something to it
}
else if (o is Sometype2) {
//cast o to Sometype2 and do something to it
}
...
else if (o is SometypeN) {
//cast o to SometypeN and do something...
I am using Apache Felix and its Declarative Services (SCR) to wire the service dependencies between bundles.
For example, if I need access to a java.util.Dictionary I can say the following to have SCR provide one:
/**
* @scr.reference name=properties interface=java.util.Dictionary
*/
protected void bindProperties(Dictionary d) {
}
pr...
Interface Builder can be used for basic dependency injection in a Cocoa app, but is anyone aware of more complete dependency injection frameworks for Objective-C/Cocoa for when you don't want to instantiate objects in a NIB file?
Edit
To clarify, I recognize that IB can be used for basic DI, but I'm looking for a framework with more co...
I'm trying to accomplish a seemingly super simple thing: from my unit test I want to replace the type being resolved with a mock/fake object.
For example: the xml config states that a component of the service IInterface should resolve to ClassA. That's fine, but from my unit test I want the type to resolve to FakeClassA instead. I can't...
How can you get castle Windsor to choose the right implantation of a interface at run time when you have multiple implementations in the container.
For example lets say i have a simple interface called IExamCalc that does calculations to work out how someone did in that exam.
No we have several implementation of this like bellow for ex...
I'm relatively familiar with the concepts of DI/IOC containers having worked on projects previously where their use were already in place. However, for this new project, there is no existing framework and I'm having to pick one.
Long story short, there are some scenarios where we'll be configuring several implementations for a given in...
Hi,
I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g.
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:
<bean id="propertyConfigurer" clas...
The examples I can find use a two layer architecture, where the controllers directly use the repository classes in the data access layer. See here or here.
Where would you register components from the data access layer if you have a service or business logic layer that uses those components? The data access layer should ideally not be r...
Hi
I'm designing a new component to a system, trying to follow the various guidelines on DI so we get payback in terms of isolation, mocking etc.
So I have the following components (illustrated as an abstraction):
Fetcher - supports IFetcher, which
fetches data from a particular data
source. Returns IDataSource.
Builder - supports I...
I am wondering how to tell NHibernate to resolve dependencies on my POCO domain objects.
I figured out that methods like CalculateOrderTax should be in the Domain object because they encode domain specific business rules. But once I have two of those I am violating SRP.
It would be no problem to extract those methods to Strategy class...
Hi,
I am building a web application that uses the database for Users, Security/roles, and to store content.
It seems a little daunting to me to begin on the road of unit testing because I have to make sure my database has been initialized properly for my tests to run.
What are common practices to help in this regard?
i.e. while devel...
Hi guys
Just a quick one.
In IOC's what does ResolveAll do?? I know that the offical answer is "Resolve all valid components that match this type." but does that mean that it will return any class that implements a given interface?
Cheers
Anthony
...
I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider.
I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementations of IBacksideP...