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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:55:40+00:00 2026-05-12T15:55:40+00:00

Yes, the title doesn’t make much sense, but here’s my situation. I have two

  • 0

Yes, the title doesn’t make much sense, but here’s my situation.

I have two interfaces, say IGen and ITrans. Some of my classes implement IGen, some implement ITrans and some implement both

ITrans has one method (Translate) and IGen has one method (Generate). For the classes that implement both ITrans and IGen Generate simply calls Translate.

I also have an Interface IGenAndTrans which is simply defined as

public interface IGenAndTrans : IGen , ITrans
{        
}

And I have a class (call it Holder) which has IGenAndTrans as a property.

[Serializable] //<- Problem
public class Holder
{
    public IGenAndTrans GeneratorAndTranslator { get; set;}
}

Now, I want to mark the class Holder with [SerializableAttribute] and use the XmlSerializer.
However I can’t do this because Holder has a property which is an interface. Normally the recommended approach would be to make IGenAndTrans an abstract base class and use XmlInclude. I’ve done this successfully in the past.

However I’m unsure of how to do that in this case. Because a lot of my classes implement both IGen and ITrans they can’t simply inherit from an abstract base class. This would mean I would need to split each of those classes into two classes with the corresponding duplication of code (since Generate calls Translate a lot of the time)

Any recommendations (if I’ve managed to explain myself well enough)? Maybe I’m too close to the code and should be implementing it differently.

  • 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-12T15:55:40+00:00Added an answer on May 12, 2026 at 3:55 pm

    I guess this is cheating because I have inside information, but I managed a bit of a specialized fix for myself.

    I realised that everything that implemented IGen also implemented ITrans. And I realised that in every class that implemented both interfaces Generate always called Translate.

    So I made a base abstract class GenerateAndTranslate that has one property called Translator and one called Generator. They both are of a new type called TranslatorBase that everything that previously implemented ITrans inherits from.

    This fix only works in my case, so I’m still interested in hearing other people’s ideas.

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

Sidebar

Related Questions

Crappy title, yes. But I honestly have no idea what this particular line of
Yes, I have searched and tried many techniques, but nothing seems to work. Here
Yes I know, this title isn't really helpfull but this is the exact problem.
(before I start I should say yes, I have done all the stupidity checks,
As the title says, here's some code: - (void)refreshMap { NSLog(@refreshing); [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
Yes, there is a similar question here . However, that question doesn't seem to
As title implies. Yes, i know it's horribad to use .abort() but hear me
For some reason jQuery.off('click') doesn't seem to be working here. When the 'Yes' button
Generally, message boxes work like this: if(ShowMessageBox(Title,Text,MB_YES_NO) == MB_YES) { //the user responded yes
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link

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.