Files
mono/mcs/class/System.Web/System.Web.UI/CollectionBuilder.cs
T
Gonzalo Paniagua Javier f9e281c517 2003-04-15 Gonzalo Paniagua Javier <[email protected]>
* list: added CollectionBuilder and TemplateBuilder.
	* System.Web.UI/CollectionBuilder.cs:
	* System.Web.UI/TemplateBuilder.cs: new classes derived from
	ControlBuilder that represent a property or a ITemplate.

	* System.Web.UI/ControlBuilder.cs: implemented all the missing bits.
	* System.Web.UI/TemplateParser.cs: added mapping from tag name to
	Type feature.

svn path=/trunk/mcs/; revision=13632
2003-04-15 03:00:06 +00:00

58 lines
1.3 KiB
C#

//
// System.Web.UI.CollectionBuilder.cs
//
// Authors:
// Gonzalo Paniagua Javier ([email protected])
//
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
//
using System;
using System.Collections;
using System.Reflection;
namespace System.Web.UI
{
class CollectionBuilder : ControlBuilder
{
Type elementType;
internal CollectionBuilder ()
{
}
public override void AppendLiteralString (string s)
{
if (s != null && s.Trim () != "")
throw new HttpException ("Literal content not allowed for " + ControlType);
}
public override Type GetChildControlType (string tagName, IDictionary attribs)
{
Type t = Parser.GetTypeFromTag (tagName);
if (elementType != null && !(elementType.IsAssignableFrom (t)))
throw new HttpException ("Cannot add a " + t + " to " + elementType);
return t;
}
public override void Init (TemplateParser parser,
ControlBuilder parentBuilder,
Type type,
string tagName,
string id,
IDictionary attribs)
{
base.Init (parser, parentBuilder, type, tagName, id, attribs);
PropertyInfo prop = parentBuilder.ControlType.GetProperty (tagName, flagsNoCase);
SetControlType (prop.PropertyType);
prop = ControlType.GetProperty ("Item", flagsNoCase & ~BindingFlags.IgnoreCase);
if (prop != null)
elementType = prop.PropertyType;
}
}
}