Here is my builder interface
public interface IContainerBuilder
{
void SetSections();
void SetSides();
void SetArea();
WebControl GetContainer();
}
and this is mine ConcreteBuilder
public class SingleContainerBuilder:BaseProperties, IContainerBuilder
{
Panel panel = new Panel();
public void SetSections()
{
//panel.Height = value coming from model
//panel.Width = value coming from model
}
public void SetSides()
{
//panel.someproperty = //value coming from model,
//panel.someotherproperty = //value coming from model,
}
public void SetArea()
{
throw new NotImplementedException();
}
public System.Web.UI.WebControls.WebControl GetContainer()
{
return panel;
}
}
and Director is here
public class ContainerBuilder
{
private readonly IContainerBuilder objBuilder;
public Builder(IContainerBuilder conBuilder)
{
objBuilder = conBuilder;
}
public void BuildContainer()
{
objBuilder.SetArea();
objBuilder.SetSections();
objBuilder.SetSides();
;
}
public WebControl GetContainer()
{
return this.objBuilder.GetContainer();
}
}
and thats how i am calling it from default page
var conBuilder = new ContainerBuilder(new SingleContainerBuilder());
conBuilder.BuildContainer();
var container = conBuilder.GetContainer();
Now problem/Confusion i am having is how do i pass Model Data to concrete classes? Reason i am confused/stuck is there could be number of different containers (more than 20-30 could be), does each different type of container has to go and grab data from model or there can be any better approach for it?
Second i am confused with, My Model is in different Library. Do i need to create a copy of model in my web project and populate my local model from that Master Model or should i directly query Master Model for Concrete Class Properties? As you can see my SingleContainer Contains BaseProperties which is local declaration of the properties that are already in Master Model and i don't see or understand the point of local Model and i am not sure i am right here or not.
Sorry i am new to Design Patterns.
Any Help will be really Appreciated,
Thanks
Aucun commentaire:
Enregistrer un commentaire