Situation:
Assembly 1
________________________ ________________________
| Class A | | Class B |
|-----------------------| |-----------------------|
| Method someMethod |---------->| Method otherMethod |
| | | |
|_______________________| |_______________________|
Assembly 1 is a application that other developers can use. We will give them only the .dll so we can publish updates from the application if we don't change the api. The developers can't change the framework in assembly 1
Methods are virtual so developers can override methods to implement there own logic if needed.
The problem is that a developer can't override otherMethod from class B, he can override it but Class A will always call the method from Class B and not the overridden method.
Assembly 1
________________________ ________________________
| Class A | | Class B |
|-----------------------| |-----------------------|
| Method someMethod |----XX---->| Method otherMethod |
| | | |
|_______________________| |_______________________|
\ |
\ |
\ |
Assembly 2 \ |
\ ________________|_______
\ | Class ExtendedB |
\ |-----------------------|
\____________>| Method otherMethod |
| |
|_______________________|
Assembly 2 haves a reference to assembly 1
Partial class doesn't work because it must be the same assembly and will not work over 2
Are there design patterns for this problem ? Or is there a other solution with reflection or something ?
EDIT Added a code example:
/* ASSEMBLY 1 */
namespace Assembly1
{
public interface IAService
{
void TestMethod3();
void TestMethod4();
}
public interface IBService
{
void TestMethod1();
void TestMethod2();
}
public class AService : IAService
{
// Base implementation of AService
public virtual void TestMethod3()
{
//do something
}
public virtual void TestMethod4()
{
//do something
}
}
public class BService : IBService
{
// Base implementation of BService
public virtual void TestMethod1()
{
//do something
}
public virtual void TestMethod2()
{
//need to call AService implementation from assembly 2
}
}
}
/* ASSEMBLY 2 */
namespace Assembly2
{
public class NewAService : AService
{
public override void TestMethod3()
{
//default implementation which could be overridden
base.TestMethod3();
}
public override void TestMethod4()
{
//default implementation which could be overridden
//An implementation of IBService Should be called
base.TestMethod4();
}
}
}