I'm reading theory about dependency inversion and decoupling and I can't see the difference between the two.
Dependency inversion talks about decoupling functional components so that higher level components don't depend on lower level components.
Decoupling talks about the same thing and how to achieve it. But then we have IoC Containe...
I am trying to use the fluent test helpers to test an AbstractRestfulFluentController
public class CustomerController : AbstractRestfulFluentController
{
private readonly IService<Customer> _customerService;
private readonly IService<CustomerAddress> _addressService;
public CustomerController(IService<Customer> customerServ...
I have the following structure -
public interface IBaseInterface<T>
{
}
public interface IChildInterface1<Class1> : IBaseInterface<Class1>
{
}
public interface IChildInterface2<Class2> : IBaseInterface<Class2>
{
}
public class ImplementationClass1 : IChildInterface1<Class1>
{
}
public class ImplementationClass2 : IChildInterface2<Cl...
Here's what I know so far:
DI lets me build reusable, unit-testable components
DI is verbose because it requires that I explicitly set the dependencies (via constructor or method. I still don't understand the interface injection though). This is why a container or a service locator is needed.
Container is better than service locator be...
I am familiar with Ninject and in Ninject you can do something similar to
Bind<ICalendar>().To<MonthCalendar>().WhenInjectedInto(typeof(Roster)).InRequestScope();
I'm not sure how to perform something similar in StructureMap. I need to be able to do this dynamically from my own binding without the use of the generic StructureMap metho...
So lets say i have this code
var builder = new ContainerBuilder();
builder.RegisterInstance(new MyType());
var container = builder.Build();
Then some time later I want to change the instance of MyType for all future resolves that are called on container.
...
I am building a framework that I don't want to couple to a particular IOC container so have created a layer on top of Ninject / structuremap etc.
I have a binding class that accepts a Func to allow binding to a method.
For example
public class Binding
{
public Type Source { get; set; }
public Func<object> Method {get; set; }
public...
Is it ok to use a container to create the objects that are going to be tested? Or should I build them manually?
...
hi,
I am creating a new application using asp.net mvc, I m using munq IOC container as my dependency injection..The issue is i want to create a new project for dependency resolution where i can register all the controllers of mvc project and the repositories of infrastructure project..I have to add Dependency Resolution project as a refe...
If I have the following setup, how can I configure my container to use the same database, when objects are created in the same context
public class Database { }
public interface IRepository { Database Database { get; } }
public interface IFooRepository : IRepository { }
public interface IBarRepository : IRepository { }
public class Foo...
I see "IoC" and "DI" mentioned pretty much everywhere for ASP.NET MVC. While I'm well aware of ... 'kind of' what these are, it's one of those almost ambiguous, amorphous floating concepts that seems to have either passed me by, or I'm just not looking in the right place. With the upcoming release of ASP.NET MVC 3.0, I'm seeing it even m...
So I currently have a master DAO class ITrackingToolDAO that has all the Service Contracts for each of my business entities.
public partial interface ITrackingToolDAO {
void Open(string connectionString);
void Close();
IBusinessFunctionDAO BusinessFunction { get; }
IBusinessUnitDAO BusinessUnit { get; }
IProgramBudg...
Hi there,
does anyone have a good example of a boostrapper class i can see for reference..
I can't seem to find one anywhere, searched google but no luck.
Searched the helpfile and no luck..
Any help really appreciated
...
Hi there,
Can anyone help?
How do i registertype with the container where the type doesn't have NO PARAMETER constructor.
Infact my constructor accepts a string .. and i normally pass in a string that represents a Path.
So when i do resolve it automatically creates the new type but passing in a string?
Thanks in advance
...
Hi
I'm trying to work out how to do the following:
[CustomAnnotation(thisVariableShouldBeInjected)]
public class MyClass
{
// Normal class stuff
}
Now the data annotation is decorating a WCF service class, which itself has constructor injection going on. Ideally I'd like to inject the annotation with a value using the Ninject IOC...
I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I...
Hi all.
Im trying to get to grips with writing testable ViewModels in Silverlight 4. Im currently using MVVM light.
Im using AutoFac and the IoCContainer is doing its job fine. However to inject into the constructor of ViewModels, which are bound to Views I have this constructor chaining:
public UserViewModel() : this(IoCContaine...
Hi All,
I'm trying to automatically register all reports in a unity container.
All reports implement IReport and also have a Report() attribute which defines the title, description and unique key (so I can read these without instantiating a concrete class).
So...
I get the report types like this
Public Shared Function GetClassesWhic...
I have a profile object in session with profile information for the currently logged in user. I wand to be able to inject it into my business classes so I can do validation etc in them without having to pass it in the parameter list in every method.
I have tried something like this in my ninject module:
Profile profile = HttpContext.C...
Hi,
I'm using Microsoft Unity. I have an interface ICustomerService and its implementation CustomerService. I can register them for the Unity container using the following code:
container.RegisterType<ICustomerService, CustomerService>(new TransientLifetimeManager());
If CustomerService has a certain parameter in its constructor (e.g...