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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:50:53+00:00 2026-06-07T22:50:53+00:00

I have a base class that has some functionality that uses type inference… public

  • 0

I have a base class that has some functionality that uses type inference…

public abstract class Processor<T>
{
    ...
    public IProcessBuilder<T, TResult> Process<TResult>(Expression<Func<T, TResult>> propertyOfT)
    {
    }

    public abstract void SetProcessors();
}

Then I have two classes:

public class EntityBase
{
    public string Name { get; set; }
}

public class EntityChild : EntityBase
{
    public string Description { get; set; }
}

And over these two I also have two processors that configure these two classes:

public class EntityBaseProcessor : Processor<EntityBase>
{
    public override void SetProcessors()
    {
        base.SetProcessors();
        this.Process(entity => entity.Name)
            .DoSomething();
    }
}

Now the problem is that I would like to reuse configured process of base entity class for the child class as well to avoid code duplication:

public class EntityChildProcessor: EntityBaseProcessor
{
    public override void SetProcessors()
    {
        base.SetProcessor();
        this.Process(entity => /* entity.Description is of course missing */)
            .DoSomething();
    }
}

Question

I’m apparently tired because I can’t seem to find a feasible way to reuse processor classes because inherited processor class should also use the inherited entity class for processing.

I can of course repeat the code and write my other processor as:

public class EntityChildProcessor: Processor<EntityChild>
{
    public override void SetProcessors()
    {
        base.SetProcessor();
        // repeated code for inherited property
        this.Process(entity => entity.Name)
            .DoSomething();
        this.Process(entity => entity.Description)
            .DoSomething();
    }
}
  • 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-07T22:50:54+00:00Added an answer on June 7, 2026 at 10:50 pm

    How would it be reasonable to you to declare EntityBaseProcessor as a generic class? Something like this:

    public class EntityBaseProcessor<TEntityBase> : Processor<TEntityBase>
        where TEntityBase : EntityBase
    {
        public override void SetProcessors()
        {
            base.SetProcessors();
            this.Process(entity => entity.Name)
                .DoSomething();
        }
    }
    
    public class EntityChildProcessor : EntityBaseProcessor<EntityChild>
    {
        public override void SetProcessors()
        {
            base.SetProcessors();
            this.Process(entity => entity.Description)
                .DoSomething();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class ActivityA that has some dialogs: public static final int
I have a abstract base C# class with a couple of methods that has
I have a base class that has methods that use a generic type in
I have a base class for many tests that has some helper methods they
I have a base controller class that exposes some logging functionality to it's child
I have a Base class that needs a Generic type. That can be either
I have an abstract base class that holds a Dictionary. I'd like inherited classes
I have a abstract base class that I have many inherited classes coming off
Our architecture uses the Repository pattern extensively. We have an abstract base class for
So I have a base class that has many children. This base class defines

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.