Say you have 3 classes that implement IDisposable - A, B and C. Classes A and B are both dependent on class C.
Would it be correct to say that classes A and B's typical implementation of Dispose() would be:
public void Dispose()
{
if (m_C != null) m_C.Dispose();
}
If there's an instance of A and and instance of B that share th...
I am trying to use structure map for the first time. I have used ioc containers before, but always with xml config. As structure map uses config through code (I know it can be done in xml as well, but most examples are using the config through code) I am running into some issues with references.
Let's work with the following example (no...
In my latest ASP.NET MVC 2 application I have been trying to put into practice the concepts of Domain Driven Design (DDD), the Single Responsibility Principle (SRP), Inversion of Control (IoC), and Test Driven Development (TDD). As an architecture example I have been following Jeffery Palermo's "Onion Architecture" which is expanded on g...
What is a good analogy to understand IoC and DI?
...
Is there any specific example/instance of DI being applied as an architectural principle or design pattern in the .NET Framework itself? Do any (or many) of the types in the framework/BCL conform to IoC?
The type names and a brief illustration/explanation based in C# would be great!
This would compund the need for DI infused design...
I'm trying to implement unit tests in my current project. After that I'll start developing using TDD further on in this project.
Yesterday I started making some tests and it wasn't as easy as it looks in theory/books.
At the moment I'm struggling with a specific scenario, which I know someone else must have worked with in the past also....
Hi, I must admit that I'm new to ASP.Net MVC and I'm currently researching all the best practices on how to start my new project. So far I have understood the concepts of the Repository Pattern and Unit of Work and I have gone onto Dependency Injection and Inversion of Control (IoC). I have been looking into this for the last 2 days an...
How can I figure StructureMap to use more than one concrete Class per Interface.
i.e. an IRepositoryCustomer is implemented by: RepositoryCustomerA and RepositoryCustomerB
How do I register and resolve this to/from the StructureMap IoC container?
...
Hi!
I´m having a little bit of trouble sorting a way to manage automatic resolved and manual dependencies in my classes.
Let´s say I have two classes to calculate prices: one calculates how much I will charge for shipping and the other how much I will charge for the entire order. The second uses the first in order to sum the shipping p...
I get an error message "Object reference not set to an instance of an object." when I try to use an UserRepos repository. Question is how can I resolve user repository at the start of the application (ASP.NET MVC) What is wrong here?
public class MyApplication : HttpApplication
{
public IUserRepository UserRepos;
public IWindsor...
I have implemented my own inversion of control methodology in MVC 2. I was thinking of reviewing MVC Turbine and possibly switch to that. However, I noticed today that MVC 3 Preview 1 has been released and has new inversion of control support built in. I know it will be a while before it is released, but wanted to see if anyone knows ...
Normally dependencies are injected via setters by the following configuration (http://static.springsource.org/sprin...beans-beanname) :
<bean id="exampleBean" class="examples.ExampleBean">
<!-- setter injection using the nested <ref/> element -->
<property name="beanOne"><ref bean="anotherExampleBean"/></property>
<!-- sett...
I'm working on a web application that uses a couple of services to synchronize data with external resources. The application and the services share the same data layer and use Castle Windsor to implement IoC.
In the web application there is the a PerWebRequest lifestyle which limits the lifetime of an instance to the lifetime of a reque...
The app I inherited uses the fluent interface for configuring our Windsor container, and it's this big glob o' configuration that's pretty disgusting.
In the past I created an extension method container.AddModule and then created modules that were passed in the container and registered services a la StructureMap for the different "modul...
For a simple application that use asp.net mvc 3 and .net-4, what service locator application is preferred, with performance concern in mind?
...
This is a problem which has been bugging me for a while now. I'm still pretty new with some of these patterns so you'll have to forgive me (and correct me) if I use any of the terms incorrectly.
My Methodology
I've created a game engine. All of the objects in my game engine use inversion of control to get dependencies. These depend...
Is there anyway to get autofac to resolve the service that has a concrete implementation with the constructor that matches a given parameter most specifically.
By this i mean match a constructor for a child type instead of matching the constructor for the base type.
For example i'd like to make the following test pass
[TestFixture]
pu...
I am new to IOC in general and I'm struggling a little to understand whether what I am trying to do makes any sense. I have a web forms application in which I want to create one module to define some bindings for me. The bindings will be used to inject repositories into my business manager classes, allowing me to unit test the business...
I am trying use NHibenate, Burrow and Ninject.
I cannot seem to be able to bind the Burrow ISession using ninject.
I currently have
Bind<ISession>().ToProvider( new BurrowFramework().GetSession()).InRequestScope();
I get the errors
"
cannot convert from 'NHibernate.ISession' to 'System.Type'
The best overloaded method match f...
I am fairly familiar with Autofac and one feature that I really love about Autofac is the registering of modules. Does anyone know how I can do this with Unity? I'm having a hard time finding which terms to use in Google to come up with the unity equivalent if there is one.
public class Global : HttpApplication, IContainerProviderAc...