unity

Is the Unity Framework any good for Inversion of Control?

I have been using IoC for a little while now and I am curious if I should use Microsoft's Unity framework (official name "Unity Application Block"). Does anyone have experience using it? So for I have been copying my IoC container code from project to project, but I think it would be better to using something standard. I think IoC can...

Any way to add some default assemblies to resolve types from in Unity / ObjectBuilder?

I'm working on my 1st project using MS Unity IoC framework. If I have this in my unity configuration: <container name="TestBusiness"> <types> <type type="PFServer.DataAccess.TestDataAccess" /> Then I get the error: Could not load type 'PFServer.DataAccess.TestDataAccess' from assembly 'Microsoft.Practices.Unity....

Is MEF a dependency injection framework ?

The recently announced managed extensibility framework (MEF) of .NET 4.0 - is it a dependency injection framework? Will Microsoft Unity from Patterns and Practices be obsolete in 4.0 ? How does MEF compare to a framework like Unity? ...

Unity Application Block, inherited injection

Hi, I am having a problem using the Unity Application Block, I have created a base class called Composition. Each Composition contains a IUnityContainer, when i create the top level object UniversalComposition i want to initialize it with a UnityContainer. Any object that gets created from the UniversalComposition I want to inject...

"List Injection" in Unity?

I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider. I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementations of IBacksideP...

UnityContainer, child container injection

Hi there, I am pretty new to the Unity Application Block and am a little stuck trying to implement the following. I have a parent and child container. When i resolve a new instance of the child container i want to inject a new UnityContainer into the constructor using the CreateChildContainer method. public class RootContainer { ...

generic type dependency injection: How to inject T

I want to handle different types of docs the same way in my application Therefore: I have a generic interface like this. public interface IDocHandler<T>where T: class { T Document { get;set;} void Load(T doc); void Load(string PathToDoc); void Execute(); void Execute(T doc); } And for different types of documents I implement thi...

Removing already registered types from UnityContainer at runtime?

hi there, i wonder if there is a simple way to remove already registered types from a unity container or at least replace existing Interface/Type mappings with another one. is it enough to just map another class type to an interface and the old one is overwritten? ...

Unity IOC Configuration

I have a class public class Broker { public Broker(string[] hosts, string endPoint, string port, Type remoteType) { } } Which I want to configure using Unity XML Configuration, I can configure it using code in C# as follows already, where "container" is my Unity container container.Configure<InjectedMembers>()...

ASP.NET MVC with Spring.NET and ModelBinder

Hi all, I'm working on a demo that makes use of Spring.NET IoC capability in ASP.NET MVC . It's kind of like the MyBlog application presented on pair programming video tutorial on www.asp.net site. I've completed the same demo using Microsoft's Unity framework and now want to try out the Spring container. To that end I've implemented a ...

Serialisation order & Unity problems

I have an application that uses an XML and custom serialiser, and have recently added some DI using Unity 1.2 to set two properties in my class. Now when I serialise the class the properties that were set by Unity are serialised first followed by all the other properties in order. So if class Properties 2 and 3 are set by Unity the ser...

Export a Unity container information to xml configuration

In Microsoft Unity you can configure a container from an existing XML configuration but is there a way to do the opposite? From an initialized container export the corresponding XML configuration? ...

How can I loosely couple database columns in a .NET application?

Hi, I have two versions of an almost identical database. Below I have created an Example table to demonstrate the basic differences, namely the ID column has changed from an Integer Identity to a GUID and various properties have been updated, in the Example archived has been replaced with readOnly and hidden: Legacy version: CREATE T...

Resolving classes without registering them using Castle Windsor

Take the following useless program: class Program { static void Main(string[] args) { IUnityContainer unityContainer = new UnityContainer(); IWindsorContainer windsorContainer = new WindsorContainer(); Program unityProgram = unityContainer.Resolve<Program>(); Program castleProgram = windsorContai...

Including a generic class in Unity App.Config file

I have a class of type ISimpleCache<IBrokeredDataObject> that I want to add as a type alias (then a type) in the App.Config file the line <typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache<IBrokeredDataObject>, MyApplication" /> is obviously wrong due to the <>, however I'm not convinced escaping th...

What is Unity InjectionConstructor Attribute ?

What is Unity InjectionConstructor Attribute and how it works ? ...

Unity framework DependencyAttribute only works for public properties?

I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties that I didn't really want exposed outside my DLLs to internal. Then I started getting exceptions. So it seems that using the [Dependency] attribute in Unity only...

Testing if a Type has been registered in Unity

Can I test if a type has been registered in a Unity container without calling for a Resolve and trapping the exception? ...

Best Practices for IOC Container

I'm using the Unity IOC container and I'm just wondering what is the best best way to access the container for multiple classes. Should every class have an IUnityContainer member and then pass the container in by constructor? Should there be a singleton class with an IOC container? How about asp.net development? Could somebody guide ...

How to use Unity's InterfaceInterceptor with Generic Interface Chain

Hi There! Right now I'm having a problem with Unity InterfaceInterceptor because it will fail when constructing the dynamic type. My classes and interfaces are something like this: public interface IService<T> { void Save(T entity); } public interface IOrderService : IService<Order> { void GetCustomerOrders(Customer custome...