I have a windows forms application contains of 3 projects in 1 solution.
Hall.Client
<-- Winforms
Hall.Admin
<-- Winforms
Hall.Processor
<-- Class Library
Hall.Client
and Hall.Admin
need Hall.Processor
as a reference. Hall.Processor
can't add reference to both Hall.Client
and Hall.Admin
because of circular dependency.
All I need is to get instance of each caller class in Hall.Processor
In Hall.Client
I have a class called Canopy
public class Canopy : System.Windows.Form
{
public void SetProcessName(string name)
{
this.txtProcessName.Text = name;
}
}
In Hall.Admin
I have a class called Roof
public class Roof : System.Windows.Form
{
public void SetProcessName(string name)
{
this.txtProcessName.Text = name;
}
}
I have a method in Hall.Processor
inside the Builder class
public class Builder
{
Form form;
public Builder(Form form)
{
//Here the main problem.
//if the caller class is Hall.Admin.Roof then this.form should be Hall.Admin.Roof
//if the caller class is Hall.Client.Canopy then this.form should be Hall.Client.Canopy
}
public void SetProcessName()
{
//How to call method in caller class directly from this class
//if(Admin.Roof) then form.SetProcessName("something about admin");
//if(Client.Canopy) then form.SetProcessName("something about client");
}
}
I need suggestion how to solve my problem. Is there any design pattern related to my problem?