Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:17:13+00:00 2026-05-25T01:17:13+00:00

Could someone please help me to understand what Unity is and how it’s simplifying

  • 0

Could someone please help me to understand what Unity is and how it’s simplifying the coding on example below:

Normal Code

FileLogger myLogger = new FileLogger();
FileLogger myLogger = new FastLogger();

Unity Container Code

// Create container and register types
IUnityContainer myContainer = new UnityContainer();
myContainer.RegisterType<ILogger, FileLogger>();       // default instance
myContainer.RegisterType<ILogger, FastFileLogger>("FastLogger");
ILogger myLogger = myContainer.Resolve<ILogger>();

Also:

  1. What is Container in Unity?
  2. What is Resolve?
  3. What is RegisterType.
  4. What is meant by Type Mapping?
  5. What is IOC

Also what happens if two classes implement the same interface and we do something like below on Unity:

container.RegisterType<IInvoicingService, InvoicingService>()
         .RegisterType<IInvoicingService, ManagerService>();
IInvoicingService service = container.Resolve<IInvoicingService>();
service.GetCount();

Looks like it’s going to invoke the getCount method on ManagerService. What should I do to invoke GetCount on InvoicingService and ManagerService?

Yes I have read the documentatation on CodePlex, it just confused me a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:17:14+00:00Added an answer on May 25, 2026 at 1:17 am

    For IOC and / or Dependency Injection i can recommend this read:

    http://martinfowler.com/articles/injection.html

    This should help you get a better understanding of what you can achieve by using this patterns. Unity helps you implement this patterns in .NET.

    I will try to answer your bulleted questions with best of my knowledge:

    • Your Container is just that: A container. It is there for you to store your Mappings in.
    • “Resolve” resolves your Interface to a concrete instance of an implementation of that particular interface. However, you only will operate on that interface, therefore making the implementation exchangeable (what is the main reason for doing this whole thing)
    • “RegisterType” typically allows you to register a concrete class for an interface. So you basically say: “This is the interface, and if someone requests this interface to be resolved, return an instance of this concrete class”. As you can see you can have default and named Type Mappings.
    • The Type Mapping is the mapping between the Interface and the implementation.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please help me to understand why the following block of code keeps
Could someone please help me to understand what the 'send()' method listed below is
Could someone please help me understand that why am I getting this error at
Could someone please help me to understand how to get all parameters passed to
Could someone here please help me understand how to determine when floating point limitations
Could someone please help me understand what the link tags are used for within
Could someone please help me how to read the XML Document below using Linq
SQL Server Mgmt Studio 2005: could someone please help me understand how to view
I've recently written this with help from SO. Now could someone please tell me
Could someone please help me out with this. I need to find the gml:pos

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.