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 for 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 the configured process of the entity base class for the child class, as well as avoid code duplication:
public class EntityChildProcessor: EntityBaseProcessor { public override void SetProcessors() { base.SetProcessor(); this.Process(entity => ) .DoSomething(); } }
Question
I'm apparently tired because I cannot find a possible way to reuse processor classes, because a legacy processor class must also use a class of inherited entities 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();
source share