unity

ResolvedParameter in Unity. Can somebody explain to when to use it?

Hi, I am sort of new to Unity all seems to be fine but I am kind of lost when to use ResolvedParameter in Unity. Googled and looked on MSDN but still cannot understand when to use it. Do you have a simple example that could illustrate it's use. Thanks a lot for your help ...

Is there a good/proper way of solving the dependency injection loop problem in the ASP.NET MVC ContactsManager tutorial?

If you don't know what I'm talking about either go through the tutorial and try to add dependency Injection yourself or try your luck with my explanation of the problem. Note: This problem isn't within the scope of the original tutorial on ASP.NET. The tutorial only suggests that the patterns used are dependency injection friendly. The...

Design Time (xml config) and run-time params using ms unity framework

I am using the MS unity framework to create a simple object factory. I have created the .config file to map interface ICAR to object CAR. It works great using the default constructor. Now, when I want to add a second constructor that takes in an int (id), I am having troubles. I have seen examples where you can pass in this param to the ...

Will ValidationHandler use the DataAnnotation Attributes?

Will the ValidationHandler in the Policy Injection Application Blocks work with DataAnnotation Attributes(for validatation) or do I need to decorate my models with the Attributes from the Validation Blocks? ...

Taking my MVC to the next level: DI and Unit of Work

I have looked at simpler applications like Nerddinner and ContactManager as well as more complicated ones like Kigg. I understand the simpler ones and now I would like to understand the more complex ones. Usually the simpler applications have repository classes and interfaces (as loosely coupled as they can get) on top of either LINQtoS...

Unity (dependency injection): How to pass in a parameter to the constructor in RegisterType

Hi there, Can anyone help? I have a wpf app (shouldn't matter) and in the Onstart i have my bootstrap stuff.. Its like this.. // Create unity container my service and repository container = new UnityContainer() .RegisterType<ISecurityRepository, SecurityRepository>() .RegisterType<ISecurityServi...

Unity in WCSF style

Hi all I am planning to use Unity for my WCF Services. The client application talks to WCF Services. The WCF services talks to few other modules [ ModuleA, ModuleB, ModuleC...] All the modules implement IModuleInitializer like WCSF modules do. They have a RegisterModuleServices method I was able to integrate Unity with WCF. In my cor...

Unity and delegate

Hi I'm using the Unity dependency injection framework. I have two classes, that each take the same delegate parameter in the constructor. Each class should get a different method when resolved. Can I set this up without using attributes ? If not how would you do it with attributes? ...

Creating objects using Unity Resolve with extra parameters

I'm using Prism, which gives be the nice Unity IoC container too. I'm new to the concept, so I haven't gotten my hands all around it yet. What I want to do now is to create an object using the IoC container, but passing an extra parameter too. Allow me to explain with an example..: I have a class that takes a commands object. This is r...

ASP.NET MVC Unity - Injecting At The Model Layer

I see tons of material on how to inject services using the ControllerBuilder.Current.SetControllerFactory but what if I wanted to resolve my services in the model? Would I have to get them from the Controller layer and pass them up? ...

Resolving interface as UIElement (Unity, PRISM, C#)

Hi, when using PRISM the normal way to hookup things with unity is to define an interface and register an implementation with this interface. Now, I have a problem regarding views. The scenario is simple: Assume a custom video control which allows to set a Play command. This control is defined by a simple interface "IPlayControlView". ...

Unity and WCF Library: Where to load unity in a wcf library?

Hi there, can anyone help? I have created a WCF library (not application) and i will be hosting this in a SVC IIS page.. But i was wanting to load the unity stuff in generic place... I could load it in the global.asax but then its tied to the IIS Asp.net container and when doing TDD this part wouldn't execute so not of my resolves wou...

Forcing WcfSvcHost.exe (WCF) to use my Custom ServiceHost (I am injecting unity stuff)?

Hi there, Is it possible to force WCFSvcHost (which is executed automatically when I do an F5 or when I am debugging another project in the solution) to use a custom ServiceHost? I have my Custom ServiceHost working great in my asp.net Host container by using a service factory which in turn calls the Custom Service Base. But when wcfS...

Unity - What are the InjectionMembers in RegisterType() calls for?

I've been working with Microsoft's Unity IOC container. There are a bunch of overloads for the RegisterType() method all looking similar to IUnityContainer RegisterType(Type t, params InjectionMember[] injectionMembers); I'm wondering when the "injectionMembers" parameters are for? I couldn't find any documentation for the them (even ...

Unity XML Config Test

We are constantly having problem with our application being broken due to the Unity configuration not being able to resolve dependencies, either the dll or namespace has been changed or is initially wrong. Can anyone point me in the right direction for writing a Test that will ensure all the Unity config files can resolve their dependen...

Unit testing with ServiceLocator

I am doing a unit test on a class that uses the unity dependency injection framework. This returns null: ServiceLocator.Current.GetInstance(); How can I get it to return a mock object or just the object itself? ...

Why won't this generics code compile?

//The class is defined like so.... public class CreateNewAccountHandler : ICommandHandler<CreateNewAccountCommand, CreateNewAccountResponse> { public CreateNewAccountResponse ExecuteCommand(CreateNewAccountCommand command) { throw new NotImplementedException(); } } //And here it the code which won...

Dependency injection with Unity and ASP.NET MVC

Hey folks, I'm attempting to use Unity as my IoC container, which "kinda" works. Snip from global.asax: protected void Application_Start() { //... left out for clarity //setup dependency injection with Microsoft Unity DependencyInjection(); } private void DependencyInjection() { va...

Typical IoC container usage - passing data down the line

I've recently started using an IoC container for the first time, but I'm not educated on the best practices for using it. More specificaly I'm using Unity in a C# .NET project, and I started using it because it came with Prism. I use the container to resolve the "top level" objects, and they get the correct objects injected based on the...

Unity in static methods

Hi, a possibly simple problem, but weird why I have no idea how to do it: Unity (PRISM) and static methods. In this special case, an extension method. But in general, how do I access a "unity provided instance" in a static method. Think e.g. of a logging service I want to access to log some stuff I am doing inside a static method. Do I...