I've literally just started using the Unity Application Blocks Dependency Injection library from Microsoft, and I've come unstuck.
This is my IoC class that'll handle the instantiation of my concrete classes to their interface types (so I don't have to keep called Resolve on the IoC container each time I want a repository in my controll...
One of the strongest accents of the Spring framework is the Dependency Injection concept. I understand one of the advices behind that is to separate general high-level mechanism from low-level details (as announced by Dependency Inversion Principle).
Technically, that boils down to having a bean implementation to know as little as possi...
I'm using constructor dependency injection in my WPF application and I keep running into the following pattern, so would like to get other people's opinion on it and hear about alternative solutions.
The goal is to wire up a hierarchy of ViewModels to a similar hierarchy of Models, so that the responsibility for presenting the informati...
Currently I am working on an application which depends on a lot of external web services. A few of them are authorize.net and chargify.
When testing(manual testing) things other than the integration with these web services, I replace these web service dependencies with fake versions of them which don't really do anything. The way I am...
In the project I'm working on I have a StructureMap registry for the main web project and another registry for my integration tests. During some of the tests I wire up the web project's registry, so that I can get objects out of the container for testing.
In one case I want to be able to replace a default concrete type from the web reg...
Hi,
I am getting back again and again to it thinking about the best way to perform validation on POCO objects that need access to some context (ISession in NH, IRepository for example).
The only option I still can see is to use Service Locator, so my validation would look like:
public User : ICanValidate {
public User() {} // We n...
Hi folks,
I've got a simple custom FilterAttribute which I use decorate various ActionMethods.
eg.
[AcceptVerbs(HttpVerbs.Get)]
[MyCustomFilter]
public ActionResult Bar(...)
{ ... }
Now, I wish to add some logging to this CustomFilter Action .. so being a good boy, I'm using DI/IoC ... and as such wish to use this pattern for my cus...
I need to inject a service based on domain property, so far I came up with the following:
ApplicationHolder.application.getServiceClass("package.${property}Service").clazz
but loading it this way doesn't inject it's dependent services. Am I doing it wrong?
...
Hi,
I have the following classes:
class Repository : IRepository
class ReadOnlyRepository : Repository
abstract class Command
abstract CommandImpl : Command
{
public CommandImpl(Repository repository){}
}
class Service
{
public Service (Command[] commands){}
}
I register them in code as follows:
var container = new Contai...
Hello Stackers :)
I have implemented the Unity DI in a project of mine, but I have, what I believe is a simple question.
My DataContext:
public partial class AuctionDataContext : DataContext {
public Table<AuctionItem> AuctionItems;
...
}
Some code for inserting an AuctionItem in the database. Please notice how I cast the inte...
I had the idea that I would write my GroovyDao as a grails service.
Next I would write a MyJavaService in java and locate it in the java sources dir in my grails app. MyJavaService contains a instance reference to groovyDao for spring injection.
I would wire up in resources.groovy the MyJavaService with a groovyDao = ref("GroovyDao")....
Hello,
I'm using StructureMap for my DI. Imagine I have a class that takes 1 argument like:
public class ProductProvider : IProductProvider
{
public ProductProvider(string connectionString)
{
....
}
}
I need to specify the "connectionString at run-time when I get an instance of IProductProvider.
I have conf...
In my web application I have various components that need to access the currently authenticated user (HttpContext.User).
There are two obvious ways a component can access this:
1) Accessing getting the User from HttpContext.Current
2) Passing the user around in constructors
Is not ideal because it makes testing difficult and ties ap...
I've already done many configs where dictionaries are passed into services in the <parameters> block.
But what I find myself needing right now is to build a NameValueCollection (allowing multiple entries with the same key) or a Collection of KeyValuePair objects.
The reason for this is im not using this dictionary to look up b when giv...
interface IUserService
class LocalUserService : IUserService
class RemoteUserService : IUserService
interface IUserRepository
class UserRepository : IUserRepository
If I have the following interfaces and classes, where the IUserService classes have a dependency on IUserRepository. I can register these components by doing something lik...
I'm experimenting with EJB3
I would like to inject a stateful session bean into a servlet, so that each user that hits the servlet would obtain a new bean.
Obviously, I can't let the bean be an instance variable for the servlet, as that will be shared. And apparantly injecting local variables isn't allowed.
I can use the new operator...
I have an interface IGenericRepository<TEntity> where TEntity : IEntity and an implementation GenericRepository<TEntity> where TEntity : Entity.
I'm trying to inject a specific IGenericRepository<Section> into a class using StructureMap:
ObjectFactory.Initialize(x =>
{
x.For(typeof(IGenericRepository<>)).Use(typ...
Hi everybody,
I am developing with NHibernate for the first time in conjunction with ASP.NET MVC and StructureMap. The CodeCampServer serves as a great example for me. I really like the different concepts which were implemented there and I can learn a lot from it.
In my controllers I use Constructur Dependency Injection to get an insta...
I was wondering if it is possible to inject a particular ActionFilterAttribute implementation using a IoC container.
For example, imagine you create a TransactionAttribute class [Transaction]
You use this to decorate action which should be wrapped in a transaction in the persistence layer. But implementation details of the attribute w...
Hi
a little background:
I am Using Spring 2.5, and specifically spring IOC and annotations.
I am using @Autowired in my code (the Autowiring is done by type)
and use @Component for exposing Classes to the Automatic wiring.
The situation described bellow arose while i tried to test my code.
now to the problem:
Note: i use a differe...