I have a question regarding mediator pattern that I want to implement in my application(using C#). While implementing the pattern in my code I came across a circular dependency. The structure of the classes as follows:
Mediator
and Colleague
components / classes are in different assemblies and as mediator pattern requires both components (classes) to use each other. The problem arises when referencing each other.
Consider the code below:
namespace Mediator
{
public abstract class IMediator
{
public IColleague colleague{get;set;}
void Register();
void Send();
}
public class MediatorA:IMediator
{
void Register(){//code here}
void Send(){//code here}
}
}
namespace Colleague
{
public abstract class IColleague
{
IMediator mediator;
void Send();
void Recieve();
}
public class ColleagueA:IColleague
{
void Send(){//code here}
void Recieve(){//code here}
}
}
as Mediater and colleague are in different namespaces and assemblies, how to resolve the circular dependency?