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 8271171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:46:35+00:00 2026-06-08T06:46:35+00:00

I defined 3 interfaces and 3 classes accordingly. Class A depends on interface B,

  • 0

I defined 3 interfaces and 3 classes accordingly. Class A depends on interface B, interface B depends on interface C and a concrete class. My sample codes look like

public interface IA
{
}

public class A : IA
{
    private IB b;

    public A(IB b)
    {
        this.b = b;
    }
}

public interface IB
{
}

public class B : IB
{
    private IC c;
    private string myValue;

    public B(IC c, string myValue)
    {
        this.c = c;
        this.myValue = myValue;
    }
}

public interface IC
{
}

public class C : IC
{
}

The special thing is class B, the constructor requires both type and a string (concrete value).

        using (IUnityContainer container = new UnityContainer())
        {
            container.RegisterType<IB, B>()
                .RegisterType<IA, A>()
                .RegisterType<IC, C>();

            IA a = container.Resolve<IA>();
        }

How shall I define in code to instruct container to inject both IC and a string value to class B?

  • 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-06-08T06:46:36+00:00Added an answer on June 8, 2026 at 6:46 am

    You can pass in an InjectionConstructor to your registration.

    container.RegisterType<IB, B>(new InjectionConstructor(container.Resolve<IC>(), "myvalue-value"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined classes: public class Parent : IParent { public string ParentText {
I have an interface defined like so: public interface IRipper { IRipperHost Host {
I have the following interfaces defined: public interface IAudit { DateTime DateCreated { get;
I have a functional AdjacencyListGraph class that adheres to a defined interface GraphStructure. In
I have the interface defined as below and is implemented by a single class
If I defined an interface in a base class and I'm calling that interface
I have the following interface defined to expose a .NET class to COM: [InterfaceType(ComInterfaceType.InterfaceIsDual)]
I have defined the following Interface [ServiceContract] public interface IHealthProducts { [OperationContract()] ResponseClass OrderSelfSignedHealthCertificate();
I have different interfaces defined in a seperate class library (assembly) and they need
I've got an enum defined in one of my Enum.cs classes inside this project

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.