(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web.UI / RootBuilder.cs
blob0da0f4de83a9df4e7fb2f9b00ecbd8738decf422
1 //
2 // System.Web.UI.RootBuilder
3 //
4 // Authors:
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc. (http://www.ximian.com)
9 //
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:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
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.
30 using System;
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;
43 static RootBuilder ()
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 ();
78 line = 1;
79 fileName = parser.InputFile;
80 Init (parser, null, null, null, null, null);
83 public override Type GetChildControlType (string tagName, IDictionary attribs)
85 string prefix;
86 string cname;
87 int colon = tagName.IndexOf (':');
88 if (colon != -1) {
89 if (colon == 0)
90 throw new Exception ("Empty TagPrefix is not valid");
92 if (colon + 1 == tagName.Length)
93 return null;
95 prefix = tagName.Substring (0, colon);
96 cname = tagName.Substring (colon + 1);
97 } else {
98 prefix = "";
99 cname = tagName;
102 Type t = foundry.GetComponentType (prefix, cname);
103 if (t != null)
104 return t;
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];
114 if (o is string) {
115 if (attribs == null)
116 throw new HttpException ("Unable to map input type control to a Type.");
118 string ctype = attribs ["TYPE"] as string;
119 if (ctype == null)
120 ctype = "TEXT"; // The default used by MS
122 Type t = htmlInputControls [ctype] as Type;
123 if (t == null)
124 throw new HttpException ("Unable to map input type control to a Type.");
126 return t;
129 if (o == null)
130 o = typeof (HtmlGenericControl);
132 return (Type) o;
135 internal AspComponentFoundry Foundry {
136 get { return foundry; }