mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
55 lines
2.1 KiB
C#
55 lines
2.1 KiB
C#
namespace System.Web.DynamicData.Util {
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.Resources;
|
|
using System.Globalization;
|
|
using IDataBoundControlInterface = System.Web.UI.WebControls.IDataBoundControl;
|
|
|
|
internal static class DataControlHelper {
|
|
internal static IDynamicDataSource FindDataSourceControl(Control current) {
|
|
for (; ; current = current.NamingContainer) {
|
|
// Don't look further than the Page, or if the control is not added to a page hierarchy
|
|
if (current == null || current is Page)
|
|
return null;
|
|
|
|
IDataBoundControlInterface dataBoundControl = GetDataBoundControl(current, false /*failIfNotFound*/);
|
|
|
|
// Not a data control: continue searching
|
|
if (dataBoundControl == null) {
|
|
continue;
|
|
}
|
|
// Return its DynamicDataSource
|
|
return dataBoundControl.DataSourceObject as IDynamicDataSource;
|
|
}
|
|
}
|
|
|
|
internal static IDataBoundControlInterface GetDataBoundControl(Control control, bool failIfNotFound) {
|
|
if (control is IDataBoundControlInterface) {
|
|
return (IDataBoundControlInterface)control;
|
|
}
|
|
IDataBoundControlInterface dataBoundControl = null;
|
|
if (control is Repeater) {
|
|
dataBoundControl = GetControlAdapter(control);
|
|
}
|
|
|
|
if (dataBoundControl == null && failIfNotFound) {
|
|
throw new Exception(String.Format(
|
|
CultureInfo.CurrentCulture,
|
|
DynamicDataResources.DynamicDataManager_UnsupportedControl,
|
|
control.GetType()));
|
|
}
|
|
|
|
return dataBoundControl;
|
|
}
|
|
|
|
internal static IDataBoundControlInterface GetControlAdapter(Control control) {
|
|
Repeater repeater = control as Repeater;
|
|
if (repeater != null) {
|
|
return new RepeaterDataBoundAdapter(repeater);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|