What's the simplest IOC container for C#? Is simple to learn and get productive with for a small app. In my case a winforms app which I want to abstract the data layer for later potential migration to a web-service for the data layer.
...
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 ?
...
On my current project, I'm stuck in an ASP.Net 2.0 Webforms anti-pattern quagmire. I am aware of the myriad of anti-patterns we're using (huge code-behinds, no separation of concerns, untestable code, and on and on). Now, I'm not interested in rescuing this application from this situation as it's too far gone. Instead, my focus is on ...
Getting going now with NInject... :)
For a WinForms application, and in particular the business logic classes used within it, is there a rule of thumb in terms of which Classes once should hook up using IOC? For example if you have a Domain Model which is modelled by C# classes is the concept that all classes should be wired together ...
Hi,
Just trying to still get my head around IOC principles.
Q1: Static Methods - Should util classes with static helper methods be wired up with IOC?
For example if I have a HttpUtils class with a number of static methods, should I be trying to pass it to other business logic classes via IOC?
Follow on questions for this might be:
...
All the examples I can find for the Unity InterfaceInterceptor require you to use Attributes to hook-up an ICallHandler to an artifact that you want to intercept. Is it possible to use an InterfaceInterceptor without needing to declare attributes so for example I can apply the interception to all classes?
...
At a certain point, during the running of my app, I want Castle.Windsor to release everything cached in memory. Is this impossible for a singleton object?
...
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 ...
I have a WCF service application that uses a component called EnvironmentConfiguration that holds configuration information for my application. I am converting this service so that it can be used by different applications that have different configuration requirements.
I want to identify the configuration to use by allowing an additi...
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 ...
How can I use StructureMap to resolve to an appropriate implementation of an interface based on a name stored in an attribute?
In my project, I have many different kinds of widgets, each descending from IWidget, and each decorated with an attribute specifying the kind of associated element.
To illustrate:
[Configuration("header")]
pub...
I'm planning to use Autofac IoC for my project where I must implement auditing (Who, What is doing in application). I was already read a lot of articles on this subject (auditing).
My intention was to use method interception to implement this functionality.
I know that Unity support this, but I was wondering if I can use Autofac for thi...
The advantage of inversion of control is that it decouples objects from specific lookup mechanisms and implementations of the objects it depends on. As a result, more flexibility is obtained for production applications as well as for testing.
what does it mean actually ?
...
I'm trying to set the DataContext on ApplicationMainWindow which is a WPF window. When I set it up in the XML like so it leaves the DataContext null:
<!-- View Models -->
<component
id="mainwindow.viewmodel"
type="ProjectTracking.ApplicationMainViewModel, ProjectTracking"
inspectionBehavior="none" l...
I'm currently designing a small system and i'm currently using structureMap as IoC. I just recently got the point of interface segregation...and I'm wondering now.
If I have a certain business object, that will implement say, three interfaces... how should I handle this in the configuration and instatiation of code?
Assuming I have two...
I'm somewhat new to Unity and dependency injection. I'm trying to write a unit test that goes something like this:
[Test]
public void Test()
{
UnityContainer container = new UnityContainer();
DynamicMock myMock = new DynamicMock(typeof(IMyInterface));
container.RegisterInstance(typeof(IMyInterface), myMock.MockInstance); //...
My case it is Ninject 2.
// normal explicit dispose
using (var dc = new EFContext)
{
}
But sometimes I need to keep the context longer or between function calls.
So I want to control this behavior through IoC scope.
// if i use this way. how do i make sure object is disposed.
var dc = ninject.Get<IContext>()
// i cannot use this ...
Still getting familiar with the limits of MonoTouch. Is there an IoC/DI library that can be used with MonoTouch. Something like Ninject ideally?
...
Given the class Ninja, with a specified binding in the Ninject kernel I can resolve an object doing this:
var ninja = ninject.Get<Ninja>();
But why can't I do this:
Type ninjaType = typeof(Ninja);
var ninja = ninject.Get<ninjaType>();
What's the correct way of specifying the type outside the call to Get?
...
Why Microsoft.Practices.ServiceLocation.IServiceLocator does not offer TryGetInstance()?
I need to get generic validator instance ServiceLocator.Current.GetInstance<IEntityValidator<TEntity>>() but not all Entities has registered validator.
The only solution i found is to use try{}catch{} block, but i dont like this approach.
...