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

  • SEARCH
  • Home
  • 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 6736801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:10:22+00:00 2026-05-26T11:10:22+00:00

From my understanding, prism’s unity container can resolve types event if they have not

  • 0

From my understanding, prism’s unity container can resolve types event if they have not been registered, does this make _container.RegisterType kinda useless ?

Thanks!

  • 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-26T11:10:23+00:00Added an answer on May 26, 2026 at 11:10 am

    If I am understanding your question correctly, what you are seeing is that Unity can (try to) make instances of classes directly, which is different from resolving types. It is perfectly reasonable to ask Unity to create a class “directly”, however, in order to leverage “Inversion of Control”, you would normally ask a container to resolve an interface, where you have mapped an interface to a class via RegisterType. This way you can map different implementations of classes to interfaces, without having to change your code, that is “Inversion of Control” and “Interfaced-based Programming” at work.

    This process involves you asking to resolve an interface, followed by Prism finding what is bound to the interface i.e. resolution, and then making an instance for you i.e. factory capabilities. The factory capabilities of Unity will ensure that any other dependencies are resolved that are required to make an instance of the resolved class e.g. using dependency injection on class constructor parameters. This whole process is recursive until all dependencies are resolved.

    For Example

    If you ask for an IFoo and it is bound Foo, Unity will try and make an instance of Foo. If Foo has a constructor which takes an IBar, Unity will try and resolve IBar and create an instance of this to use in the constructor for IFoo.

    So in the following code:

    We can resolve IFoo as described above.

    We can make an instance of class Bar directly, as it has no dependencies.

    We can make an instance of class Foo directly, as it has a dependency on IFoo, but we have registered it.

    We cannot make an instance of Woo directly as there is no registration for IYay.

    //Types
    public interface IBar{}
    public class Bar : IBar {}
    
    public interface IFoo{}
    public class Foo : IFoo{ public Foo(IBar bar) {} }
    
    public interface IYay{}
    public class Woo { Woo(IYay yay){} }
    
    //Registrations
    container.RegisterType<IFoo, Foo>();
    container.RegisterType<IBar, Bar>();
    
    //Resolve IFoo
    IFoo foo = container.Resolve<IFoo>();
    
    //Create Bar directly
    Bar bar = container.Resolve<Bar>();
    
    //Create Foo directly
    Foo foo = container.Resolve<Foo>();
    
    //Create Woo directly - won't work as IYay is not registered!
    Yay yay = container.Reolve<Yay>();
    

    In the example above RegisterType is used to map a concrete implementation to an interface. It is at this point that we can map any implementation we want and this will ripple throughout our program as long as the container is always used to resolve types.

    For example, if we change what IBar is mapped to, then any time IFoo is resolved it will be created with that different implementation of IBar. This gives us a substantial way of altering a program’s behaviour by just changing a single line of code i.e. RegisterType.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some not understanding actions from gnu clisp Suppose, I have some code
From my understanding of .NET, if I use a BackgroundWorker and have an event
From my understanding, Lua is an embeddable scripting language that can execute methods on
My understanding of Hibernate is that as objects are loaded from the DB they
From my understanding JSONP can only be achieved using the GET verb. Assuming this
From my understanding, SIGPIPE can only occur as the result of a write() ,
from my understanding obited can do both comet and xmpp ? it is better
I have difficulty understanding SELECT * FROM myTable WHERE 0 = ... in the
I have been fighting all day in understanding Dijkstra's algorithm and implementing with no
Either I am not totally understanding how events work or Delphi Prism has gone

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.