// mybuilderusing system; using system.collections;
/// product /// class HomePage {// Fields private string pagetype; private string samplecode; private Hashtable parts = new Hashtable (); // Construcrors public HomePage (string pagetype) {this.pagetype = pagetype; samplecode = "< HTML>
parttable, partspan body> html> ";} // indexers public object this [string key] {get {return parts [key];} set {parts [key] = value;}}// Methods public void PrintHTMLCode () {samplecode = samplecode.Replace ( "parttable", parts [ "table"] ToString ().);. Samplecode = samplecode.Replace ( "partspan", parts [ "span"] ToString ( )); Console.writeline;}
}
/// product ///// directorclass PageDirector {public void Construct (PageBuilder pagebuilder) {pagebuilder.BuildFrame (); pagebuilder.BuildTable (); pagebuilder.BuildSpan ();}}; // director /// builder // / abstract class PageBuilder {// Fields protected HomePage homepage; // Properties public HomePage HomePage {get {return homepage;}} // Methods abstract public void BuildFrame (); abstract public void BuildTable (); abstract public void BuildSpan (); }
class CoolBuilder: PageBuilder {override public void BuildFrame () {homepage = new HomePage ( "coolpage");} override public void BuildTable () {homepage [ "table"] = "