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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:39:38+00:00 2026-06-08T21:39:38+00:00

I know what it means but want elegant solution to this problem. For a

  • 0

I know what it means but want elegant solution to this problem. For a work around solution, I can create methods with different signatures, but that won’t satisfy me.
My scenario is as below:

public interface IDomainToViewMapper<TModel, TViewModel>
{
    TViewModel MapDomainToView(TModel source);
}

public interface ISiteMapper : IDomainToViewMapper<Site, ViewModelOne>,
                               IDomainToViewMapper<Site, ViewModelTwo>
{    }

Now when I write my main implementation class, I get member with same signature issue. I can go ahead and implement interface explicitly, but because we are injecting dependencies on the fly, I can’t cast to interface, which will again be ambiguous.

    public SiteMapper : ISiteMapper
{
    public ViewModelOne MapDomainToView(Site site) { ... }
    public ViewModelTwo MapDomainToView(Site site) { ... }      
}

Any elegant solution to the issue would be great

  • 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-08T21:39:40+00:00Added an answer on June 8, 2026 at 9:39 pm

    Your SiteMapper is basically a Factory if I understand your design, make your SiteMapper method MapDomainToView return a list of ViewModels for a given Site, add a method where you can Register ViewModels for a specific Site, store this mapping in a Dictionary for example.

    Or use Castle Windsor or your favorite IoC container in stead of SiteMapper or possibly internally in SiteMapper

    Example:

    public interface IViewModel
    {
    }
    
    public class ViewModelOne : IViewModel
    {
    }
    
    public class ViewModelTwo : IViewModel
    {
    }
    
    
    public class SiteMapper 
    {
        private Dictionary<Site, List<IViewModel>> map { get; set; }
    
        public void Register(Site site, IViewModel viewModel)
        {
            // Add combination to map
        }
    
        public List<IViewModel> MapDomainToViews(Site site) 
        {
            if (map.ContainsKey(site))
                return map[site];
            else
                ....
        }
    }
    

    This is a simple IoC, if you go this route check out Castle, Unity, NInject etc

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

Sidebar

Related Questions

I know I can do this with a CTE or another means but I
I now want to know that means this line: printf(Answer: %00010.6f, 22); He prints:
I don't know if hashing is the right word for this, but I want
I know this might seem a controversial question but it really is not meant
I know what this error means, the unusual thing it whats throwing it. EntitySave(arguments.entity);
Anyone know what this error means? after googling I found a bunch of sites
Does anyone know what this warning means? It is followed by the error: Command
Does anyone know what this error message means? FATAL: Code generation error detected during
I know that the RoR can do the validation in the models. But I
I want to know if there is any easy/elegant way to determine the source

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.