I want to use Unity resolve IService to two different implementations, to make use of a wrapper class, the equivalent of:
IService service = new DispatcherService(new RealService(), Application.Current.Dispatcher);
Where both DispatcherService and RealService implement the IService interface.
I have a library containing some service...
In the C# language, using StructureMap 2.5.4, targeting .NET Framework 3.5 libraries.
I've taken the step to support multiple Profiles in a structure map DI setup, using ServiceLocator model with Bootstrapper activation. First setup was loading default registry, using the scanner.
Now I like to determine runtime what Registry configur...
I am trying out the code from this post on Event Driven Architecture (very interesting by the way). His IOC container is Unity though and I would like to do this using Structure map.
His code is:
public class EventSubscriptions : ISubscriptionService
{
public static void Add<T>()
{
var consumerType = typeof(T);
con...
Im attempting to use the MVP design pattern with a Swing application in conjution with Spring IOC. In MVP the View needs to pass itself into the presenter, and I can't work out how to do this with Spring.
public class MainView implements IMainView {
private MainPresenter _presenter;
public MainView() {
_presenter = n...
Recently I developed a performance tester console application, with no UI, with the help of a IoC containter (Castle-Windsor-Microkernel). This library enabled me to let the user choose which test(s) to run, simply by changing the configuration file.
Have I realized what IoC containers are about? I'm not sure. Even Joel said here on SO ...
I was wondering when do I use buildup and when do I use resolve, when using the Unity IOC.
And when do I call teardown?
Thanks
...
Here are the relevant types and an example of the handler I want linked to IHandle<EventA> and IHandle<EventB>:
// marker interface
public interface IEvent {}
public interface IHandle<TEvent> where TEvent : IEvent {
void Handle(TEvent e);
}
public class SomeHandler : IHandle<EventA>, IHandle<EventB> {
public void Handle(EventA...
I'm building an ASP.NET MVC application that uses a DDD (Domain Driven Design) approach with database access handled by NHibernate. I have domain model class (Administrator) that I want to inject a dependency into via an IOC Container such as Castle Windsor, something like this:
public class Administrator
{
public virtual int Id { g...
Hi,
I have some trouble implementing the Unity IOC into my project reading from config file.
Here is what I have
1) ClasslibraryA
2) ClasslibraryB that references ClasslibraryA
3) Winforms App that references ClasslibraryB
Note: SomeOther app will reference ClassLibraryA, eg. a web service.
ClasslibraryA will have to be configured...
I'm programmatically registering a group of services that all implement the same interface, IRule. I have another service that looks like this:
public class MyService {
private IEnumerable<IRule> _rules;
public MyService(IEnumerable<IRule> rules){
_rules = rules;
}
}
Hammett posted something that looked like what ...
Considering this code :
interface IRepository<T>
{
void Save();
}
class Repository<T>
{
public virtual void Save() // something
{ }
}
interface IOtherRepository : IRepository<OtherClass>
{
void Other();
}
class OtherRepository : Repository<OtherClass>, IOtherRepository
{
public override void Save() // something d...
I have a medium sized asp.net MVC app. It consumes a service layer that handles all the repository use, calling domain services, etc. My controller actions are very slim -- they basically call a service class, get a response and show that respose. Most components are interface based with some poor man's DI. The app is growing, needs ...
I know this is somewhat of a dead horse, but I'm not finding a satisfactory answer. First let me say, I am NOT dealing with a web app, otherwise managing NH Session is quite simple.
I have a bunch of enterprise components. Those components have their own service layer that will act on multiple repositories. For example:
Claim Compo...
I have a InventoryController that gets a IInventoryRepository inyected, however my needs have changed, and now one of the controllers methods also needs to use another 2 repositories, ILoansRepository (to see the get info about loaned inventory items) and another one, where some stats and extra info are found.
The way it works is that a...
I would like to use Ninject in my WinForms application. I cannot figure out how to use it for my user controls. Sometimes they rely on the services I want to configure through the DI framework. These controls need to be manageable through the designer (thus need default constructors).
So, is there a way to inject dependencies into pr...
I'd like to instantiate a class by name (a string) without specifying a namespace or assembly. Like this (Unity syntax):
var processor = container.Resolve<IProcessor>("SpecialProcessor");
would instantiate the first IProcessor it finds called SpecialProcessor. Maybe
MyNamespace.SpecialProcessor
I'd like to avoid having to create ...
Hi - Im new to IOC and StructureMap and have an n-level application and am looking at how to setup the wirings (ForRequestedType ...) and just want to check with people with more experience that this is the best way of doing it!
I dont want my UI application object to reference my persistence layer directly so am not able to wire everyt...
I'm using the Unity IoC container for resolving my objects. However, I've run into an issue. When I have more than one constructor - how does Unity know which one to use? It seems to use the one with parameters when I have one with and one without. Can I explicitly tell it which constructor to use?
Specifically I had a case similar to ...
I want to convert something like this:
<components>
<component id=""service1"" service=""WindsorTests.IService, MyAssembly"" type=""WindsorTests.Service1, MyAssembly""/>
<component id=""service2"" service=""WindsorTests.IService, MyAssembly"" type=""WindsorTests.Service2, MyAssembly""/>
<component id=""consumer"" typ...
I heard a lot of people saying that it is a bad practice to use IoC.Resolve(), but I never heard a good reason why (if it's all about testing than you can just mock the container, and you're done).
now the advantages of using Resolve instead of Constructor Injection is that you don't need to create
classes that have 5 parameters in the...