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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:46:41+00:00 2026-05-18T05:46:41+00:00

in my implementation, I have an interface as: ICachingManager . I’ve got now one

  • 0

in my implementation, I have an interface as: ICachingManager. I’ve got now one implementation. I also created a manager class as:

public class CachingManager
{
    #region Members
    private ICachingManager service;
    #endregion

    #region Constructors
    public CachingManager(ICachingManager service)
    {
        this.service = service;
    }
    #endregion

    #region Public Methods
    public void EnCache<T>(string key, T value)
    {
        this.service.EnCache<T>(key, value);
    }

    public T DeCache<T>(string key)
    {
        return this.service.DeCache<T>(key);
    }
    #endregion
}

In case I had one implementation, then I can easily register the CachingManager class with Unity, automatically Unity resolves and injects the ICachingManager.

In case I had more than one implementation using named types, then how can I can make use of Unity? Do I need to make use of an Abstract Factory to decide on which named type to initialize?

Is it a good idea to make use of such a composite class or use directly implementations of the interface with Abstract Factory?

  • 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-18T05:46:42+00:00Added an answer on May 18, 2026 at 5:46 am

    You don’t have to create an abstract factory. You can inject a given named implementation:

    public class MyClient
    {
        [Dependency("NamedManager")]
        public ICachingManager CachingManager { get; set; }
    
        // or in the constructor
        public MyClient([Dependency("NamedManager")] ICachingManager cachingManager) {
           // ...
        }
    }
    

    or you can configure the container to do the same thing:

    public class MyClient
    {
        public MyClient(ICachingManager cachingManager) {
           // ...
        }
    }
    ...
    void ContainerBuilder() {
       ...
       Container.RegisterType<MyClient>(
           new InjectionConstructor(
              new ResolvedParameter<ICachingManager>("NamedManager")));
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have an interface 'IA' for which we have an implementation 'A'.
I have interface: public interface CartService extends RemoteService{ <T extends ActionResponse> T execute(Action<T> action);
I have an interface thus: public interface Doer { public void do(Object arg); }
Just for learn: Say we have: interface Musician { /* content skipped */ }
Lets say you have interface definition. That interface can be Operation . Then you
I recently seen some C# code where the interface declaration and implementation where in
import java.util.Collection; import example.Event; public interface Query { public boolean hasMore (); public Collection<Event>
Having problems with out of scope for NSDate in an iphone app. I have
I'm sure that my problem is common and I almost sure that it doesn't
I will choose Java as an example, most people know it, though every other

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.