Questions tagged [unity-application-block]

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

The Unity Application Block (Unity) is a lightweight, extensible dependency injection container for .NET. It also supports interception.

Unity targets both .NET CLR and Silverlight.

Installing Unity can most easily be done using its NuGet package:

Install-Package Unity

More information at:

Hello world in c#

interface IMessageWriter {
    void WriteMessage(string message);
}

class ConsoleWriter : IMessageWriter {
    public void WriteMessage(string message) { Console.WriteLine(message); }
}

class HelloWorldService {
    private readonly IMessageWriter _writer;

    public HelloWorldService(IMessageWriter writer) {
       _writer = writer;
    }

    public void Go() {
       _writer.Write("Hello World!");
    }
}

using (var container = new UnityContainer()) {        
    container.RegisterType<IMessageWriter, ConsoleWriter>();

    var helloWorldService = container.Resolve<HelloWorldService>();

    helloWorldService.Go();    
}
5 questions
11
votes
6 answers

Dependency Injection for Windows Phone 7

I was trying to use Unity 2.0 beta 2 for Silverlight in my Windows Phone 7 project and I kept getting this…
Igor Zevaka
  • 74,528
  • 26
  • 112
  • 128
1
vote
1 answer

Use ASP.NET MVC Unity for Data Caching

I have a ASP.Net MVC project running on .NET 4.6.1 Framework. I have recently added Unity.Mvc 5 IoC framework for dependency injection In order to have flexibility for unit testing and other, I moved my Unity Configuration to a separate class…
1
vote
0 answers

Firebase Database Unity offline support

I am building a chat system using firebase database in unity, but unlike all other platforms I was not able to find an offline support for database in unity. Is there any way by which we can enable the offline support?
1
vote
2 answers

Dependency injection with Unity Application Block

I am trying to learn about dependency injection and i'm using the unity application block to help. What I want to do is, have a console app that will register a class (as long as it implements a specific interface) and execute a method... So the…
SteveCl
  • 4,529
  • 6
  • 29
  • 38
0
votes
0 answers

Microsoft.Practices.Unity configuration issue - System.TypeInitializationException

I have implement the Microsoft unity application block in one of my project. Project's Unity configuration file is:
Piuiui
  • 11
  • 4