Files
mono/mcs/class/System.Web/System.Web.UI/DataBinder.cs
T
Gonzalo Paniagua Javier 865ba07b1a 2002-06-19 Gonzalo Paniagua Javier <[email protected]>
* System.Web.UI/CompiledTemplateBuilder.cs: new file. Used in the
	code generated by xsp.

	* System.Web.UI/Control.cs:
	(BindingContainer): implemented.
	(EnsureChildControls): avoid stack overflow.

	* System.Web.UI/DataBinder.cs: implemented Eval and PropertyValue.

	* System.Web.UI.WebControls/Repeater.cs:
	(Controls):
	(OnDataBinding): fixed stack overflow.

	Still need more work in Repeater.cs to make it render.

svn path=/trunk/mcs/; revision=5345
2002-06-19 14:49:12 +00:00

78 lines
1.8 KiB
C#
Executable File

//
// System.Web.UI.DataBinder.cs
//
// Authors:
// Duncan Mak ([email protected])
// Gonzalo Paniagua Javier ([email protected])
//
// (C) 2002 Ximian, Inc. (http://www.ximian.com)
//
using System;
using System.Reflection;
namespace System.Web.UI {
public sealed class DataBinder
{
public DataBinder ()
{
}
public static object Eval (object container, string expression)
{
return GetPropertyValue (container, expression);
}
public static string Eval (object container, string expression, string format)
{
return GetPropertyValue (container, expression, format);
}
[MonoTODO]
public static object GetIndexedPropertyValue (object container, string expr)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static string GetIndexedPropertyValue (object container, string expr, string format)
{
throw new NotImplementedException ();
}
public static object GetPropertyValue (object container, string propName)
{
if (container == null || propName == null)
throw new ArgumentException ();
Type type = container.GetType ();
PropertyInfo prop = type.GetProperty (propName);
if (prop == null)
throw new HttpException ("Property " + propName + " not found in " +
type.ToString ());
MethodInfo getm = prop.GetGetMethod ();
if (getm == null)
throw new HttpException ("Cannot find get accessor for " + propName +
" in " + type.ToString ());
return getm.Invoke (container, null);
}
public static string GetPropertyValue (object container, string propName, string format)
{
object result;
result = GetPropertyValue (container, propName);
if (result == null)
return String.Empty;
if (format == null)
return result.ToString ();
return String.Format (format, result);
}
}
}