I have two classes, Class A and Class B, that implement a delegate with Methods A and B. Their implementations of Methods A and B might look like:
Class A {
Method A {
Action 1;
Action 2;
Action 3;
}
Method B {
Action 4;
Action 5;
Action 6;
}
}
Class B {
Method A {
Action 2;
Action 3;
}
Method B {
Action 4;
Action 5;
}
}
The two classes implement two delegate methods that are almost identical except Class B performs less actions than Class A in each method. Is there a way I can factor out Class B's implementation into a delegate class that is shared by both classes, and somehow "inject" Action 1 and Action 6 into the delegate methods when needed (for Class A)? If not, what would be the best way to structure this code?
Edit: Also, in the actual implementation, Class A and Class B are pretty different except for the fact that they implement methods A and B in a similar fashion.