2 // System.Web.UI.CollectionBuilder.cs
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
11 using System.Collections;
12 using System.Reflection;
14 namespace System.Web.UI
16 sealed class CollectionBuilder : ControlBuilder
20 internal CollectionBuilder ()
24 public override void AppendLiteralString (string s)
26 if (s != null && s.Trim () != "")
27 throw new HttpException ("Literal content not allowed for " + ControlType);
30 public override Type GetChildControlType (string tagName, IDictionary attribs)
32 Type t = Root.GetChildControlType (tagName, attribs);
33 if (elementType != null && !elementType.IsAssignableFrom (t))
34 throw new HttpException ("Cannot add a " + t + " to " + elementType);
39 public override void Init (TemplateParser parser,
40 ControlBuilder parentBuilder,
46 base.Init (parser, parentBuilder, type, tagName, id, attribs);
48 PropertyInfo prop = parentBuilder.ControlType.GetProperty (tagName, flagsNoCase);
49 SetControlType (prop.PropertyType);
51 prop = ControlType.GetProperty ("Item", flagsNoCase & ~BindingFlags.IgnoreCase);
52 elementType = prop.PropertyType;