Skip to main content

Questions tagged [unity-container]

The Unity Application Block (i.e. Unity) is a lightweight, extensible dependency injection container for .NET with support for interception.

2 votes
0 answers
567 views

I am using OWIN to self host a WebAPI service. There is Unity to serve as an IoC container. Within several OWIN middlewares (e.g. authorization layer) as well as in WebAPI I need to access a Unity ...
Ondra Netočný's user avatar
2 votes
2 answers
611 views

I have written a wrapper around the Microsoft's Unity container and would like this to be cod reviewed please. Here is the interface definition: ...
Yawar Murtaza's user avatar
9 votes
1 answer
13k views

I am learning design patterns and this is my sample code where I have implemented Factory pattern and instance creation I have delegated to Unity container Framework(DI) to build the loosely coupled ...
Shreekanth Gaanji's user avatar
2 votes
0 answers
1k views

I wanted to cache methods using unity interception and not have the parameters passed in stay alive for the sake of caching. If the objects would have gone out of scope without caching then the cache ...
CharlesNRice's user avatar
  • 4,438
1 vote
1 answer
1k views

I have a situation where I have a static class that reads my application configuration file for some configuration value. When unit testing Web API controllers that make use of this static class I am ...
Sykomaniac's user avatar
3 votes
2 answers
8k views

I just finished the Pluralsight courses about Inversion of Control and Mirco-ORMs, and I am struggling with the implementation aspect of some of the concepts. This is my (simplified) repository ...
Xavier Peña's user avatar
2 votes
0 answers
1k views

I created an application from 3 layers, DAL, BLL, and Representation layer in ASP.NET Web API. In DAL i have 4 Classes: - DatabaseContext.cs, UnitOfWork.cs, GenericRepository and UserInfo. In BLL i ...
Kob_24's user avatar
  • 131
4 votes
1 answer
4k views

When I started learning Repository Pattern with Unity few days ago I was under impression that the main benefit of this pattern is the separation of data layer from the business layer. In other words,...
Robert J.'s user avatar
  • 175
3 votes
1 answer
595 views

I am now developing a product, which will use Unity & Repositories when it comes to data management. I will demonstrate on a simple example. What we want to do, ...
Robert J.'s user avatar
  • 175
12 votes
1 answer
38k views

I'm just learning how dependency injection and mocking work, but I'd like some feedback on how I'm setting up a couple of tests. I can get them to pass, but I'm not sure this is all I need. This is ...
madvora's user avatar
  • 221
3 votes
3 answers
5k views

I have been using Microsoft.Unity as my container and have decided that the approach for a lazy implementation causes too much rework. Each time you decide to swap ...
sQuir3l's user avatar
  • 209
8 votes
1 answer
21k views

I'm working on a generic repository using EF 6 code first and trying to following the Unit of Work pattern. Unity is being used to inject my repositories, and I'm trying to get everything supporting ...
jdylanmc's user avatar
  • 183
5 votes
1 answer
1k views

After a somewhat lengthily discussion in the chat room, I have set up an IoC container with Unity to store my settings in. This is my static IoC class: ...
user avatar