unity

Is it possible to configure ms Unity container from an xml document and NOT from a file?

Is it possible to configure ms Unity container from an xml document and NOT from a file? thx ...

Unity Framework's container type's constructor param's type...

Currently I am trying to use a config file to give Unity Framework information that looks like this... <configuration> <unity> <typeAliases> <typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity, Culture=neutral, Version=1.1.0.0, PublicKeyToken=31bf3856ad364e35"...

Unity & StructureMap

Are there equivalent for StructureMap of this in Unity: ServiceLocator.Current.GetAllInstances<IT> Trying to follow this little pattern... ...

How to perform property injection with Unity and asp.net mvc on action filters?

I am trying to get dependency injection working on my action filters with property injection. I can't figure out how to automatically set dependencies on the filters. Here is the code I have so far. public class UnityActionInvoker : ControllerActionInvoker { IUnityContainer container; public UnityActionInvoker(IUnityContainer ...

Unity Dependency Injection - how to RegisterInstance in .config?

This is a C# Asp.net MVC project. I've currently got the Unity mappings set up in the global.asax.cs. I'd like to move the container setup from code, to the web.config. All has gone fine with my own types, but now I need to translate this line : container.RegisterInstance(System.Web.Security.Membership.Provider); (All the other co...

Dependency Injection and ModelStateWrapper

Hi, in tutorial Validating with a service layer constructor for Product Service looks like this: ProductService(IValidationDictionary validationDictionary, IProductRepository repository) and its instance in default controller constructor is created like this: public ProductController() { _service = new ProductService(new Mode...

Unit testing data access layer using Unity Framework

I am getting close to finish my database, so far, 16 tables so far, and I need to unit test my DAO layer for this ASP.NET project. I am using the Unity Framework to decouple the layers, so I expect that I should be able to assign the DAO layer to my unit tests, which will be testing against the interfaces since the concrete classes are ...

Can I pass constructor parameters to Unity's Resolve() method?

I am using Microsoft's Unity for dependency injection and I want to do something like this: IDataContext context = _unityContainer.Resolve<IDataContext>(); var repositoryA = _unityContainer.Resolve<IRepositoryA>(context); //Same instance of context var repositoryB = _unityContainer.Resolve<IRepositoryB>(context); //Same instance...

Can a unity container pass a reference of itself as a constructor parameter?

Greetings Is there a way for a unity container to pass itself to an object? i.e.: public class Something { public Something(IUnityContainer container) { ... } } Thank you for the help. ...

Unity mode for Remote Desktop

I typically have several remote desktop sessions going at the same time. Within these sessions I might be running different applications. VMWare Workstation has a Unity mode that allows you to integrate guest applications with the host. I'd like to be able to do the same thing for remote desktop sessions. It would be a real productiv...

how to pass the same viewmodel to a child view using unity?

Hi there, I have a business object, lets say customer, it has too many fields to show in one page, so I'm splitting it to different tab pages. the data is not in a way that I can split it into meaningful bits (like address, having state, street name and so on), so I decided to keep the same model and view model and have different views ...

Prism Silverlight LoadModule and pass data

I'm loading a module dynamically on demand to edit a business object (let's say a customer module). I want to then load the module and pass a customerDTO (or a primary key) to the view model. I have the OnClick command on my button to trigger my ICommand and then I load the CustomerModule: private void EditCustomer(Guid customerID) ...

anonymous functions in unity via config file

I've been using unity with interfaces, but sometimes created an interface only to use a single method in a single class; and used unity as my IoC framework. But then I saw this post: http://codebetter.com/blogs/karlseguin/archive/2009/05/08/making-the-untestable-testable-with-anonymous-methods-and-dependency-injection.aspx which made m...

How to register same type twice with different constructors in Unity?

I'm trying to register the same type but with two different constructors. When I trying to resolve, I get "Resolution of the dependency failed" on the second Resolve. var container = new UnityContainer(); container.RegisterType<IBar, Bar>() .RegisterInstance(new Bar()) .RegisterType<IBar, Bar>() .Regist...

Is there TryResolve in Unity?

How can I make Unity not to throw ResolutionFailedException if Resolve fails? Is there something like TryResolve? var container = new UnityContainer(); var foo = container.TryResolve<IFoo>(); Assert.IsNull(foo); ...

How do I configure Unity to create a class that takes two different items of same type?

I am still getting started with Unity, and have what seems to be a simple question. I have a class that has a dependency on two different instances of the same interface. How do I configure and resolve this class? I.E. Given: public interface ILogger { void Write(string message); } public class ConsoleLogger : ILogger { publi...

{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

Hello, I have built a simple application framework around Unity. I.e. Form and user controls are discribed as xml and built dynamically. I have a form which contains a ComboBox which when closed causes the error detailed below. The problem does not occur if the ComboBox is substituted for a ListBox control. Some googling raised som...

Inject same DataContext instance across several types with Unity

Suppose I have IRepository interface and its implementation SqlRepository that takes as an argument LINQ to SQL DataContext. Suppose as well that I have IService interface and its implementation Services that takes three IRepository, IRepository and IRepository. Demo code is below: public interface IRepository<T> { } public class SqlRe...

Using Unity Application Block in commercial programm (Ms-PL)

Hello, i´have read the Ms-PL under the Homepage of Unity, but its not clear for me what i need to do, when i use Unity in my commercial programm? I only use the binary files and i want to distribute them along with my programm. Do i have to provide a license-file anywhere? Do i have to tell anywhere in my programm that i´m using Unit...

MVC, Dynamic routing, Unity, Determine if current controller exists in global.asax

What I'm trying to do is dynamic routing for my application. For instance, in Application_BeginRequest() I want to get the current controller and determine if it exists. If not, I want to add a set of routes that override the default routing so that my url looks like this mysite.com/term from database But, if the "term from databas...