2 // System.Web.UI.RootBuilder
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2003 Ximian, Inc. (http://www.ximian.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System
.Collections
;
32 using System
.Web
.Compilation
;
33 using System
.Web
.UI
.HtmlControls
;
35 namespace System
.Web
.UI
37 public sealed class RootBuilder
: TemplateBuilder
39 static Hashtable htmlControls
;
40 static Hashtable htmlInputControls
;
41 AspComponentFoundry foundry
;
45 htmlControls
= new Hashtable (new CaseInsensitiveHashCodeProvider (),
46 new CaseInsensitiveComparer ());
48 htmlControls
.Add ("A", typeof (HtmlAnchor
));
49 htmlControls
.Add ("BUTTON", typeof (HtmlButton
));
50 htmlControls
.Add ("FORM", typeof (HtmlForm
));
51 htmlControls
.Add ("IMG", typeof (HtmlImage
));
52 htmlControls
.Add ("INPUT", "INPUT");
53 htmlControls
.Add ("SELECT", typeof (HtmlSelect
));
54 htmlControls
.Add ("TABLE", typeof (HtmlTable
));
55 htmlControls
.Add ("TD", typeof (HtmlTableCell
));
56 htmlControls
.Add ("TH", typeof (HtmlTableCell
));
57 htmlControls
.Add ("TR", typeof (HtmlTableRow
));
58 htmlControls
.Add ("TEXTAREA", typeof (HtmlTextArea
));
60 htmlInputControls
= new Hashtable (new CaseInsensitiveHashCodeProvider (),
61 new CaseInsensitiveComparer ());
63 htmlInputControls
.Add ("BUTTON", typeof (HtmlInputButton
));
64 htmlInputControls
.Add ("SUBMIT", typeof (HtmlInputButton
));
65 htmlInputControls
.Add ("RESET", typeof (HtmlInputButton
));
66 htmlInputControls
.Add ("CHECKBOX", typeof (HtmlInputCheckBox
));
67 htmlInputControls
.Add ("FILE", typeof (HtmlInputFile
));
68 htmlInputControls
.Add ("HIDDEN", typeof (HtmlInputHidden
));
69 htmlInputControls
.Add ("IMAGE", typeof (HtmlInputImage
));
70 htmlInputControls
.Add ("RADIO", typeof (HtmlInputRadioButton
));
71 htmlInputControls
.Add ("TEXT", typeof (HtmlInputText
));
72 htmlInputControls
.Add ("PASSWORD", typeof (HtmlInputText
));
75 public RootBuilder (TemplateParser parser
)
77 foundry
= new AspComponentFoundry ();
79 fileName
= parser
.InputFile
;
80 Init (parser
, null, null, null, null, null);
83 public override Type
GetChildControlType (string tagName
, IDictionary attribs
)
87 int colon
= tagName
.IndexOf (':');
90 throw new Exception ("Empty TagPrefix is not valid");
92 if (colon
+ 1 == tagName
.Length
)
95 prefix
= tagName
.Substring (0, colon
);
96 cname
= tagName
.Substring (colon
+ 1);
102 Type t
= foundry
.GetComponentType (prefix
, cname
);
105 else if (prefix
!= "")
106 throw new Exception ("TagPrefix " + prefix
+ " not registered");
108 return LookupHtmlControls (tagName
, attribs
);
111 static Type
LookupHtmlControls (string tagName
, IDictionary attribs
)
113 object o
= htmlControls
[tagName
];
116 throw new HttpException ("Unable to map input type control to a Type.");
118 string ctype
= attribs
["TYPE"] as string;
120 ctype
= "TEXT"; // The default used by MS
122 Type t
= htmlInputControls
[ctype
] as Type
;
124 throw new HttpException ("Unable to map input type control to a Type.");
130 o
= typeof (HtmlGenericControl
);
135 internal AspComponentFoundry Foundry
{
136 get { return foundry; }