// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002 Ximian, Inc. (http://www.ximian.com)
-//
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
-using System.Web;
+using System.Security.Permissions;
using System.Web.Compilation;
using System.Web.Util;
namespace System.Web.UI {
- public abstract class TemplateControl : Control, INamingContainer
- {
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+ public abstract class TemplateControl : Control, INamingContainer, IFilterResolutionService {
+#else
+ public abstract class TemplateControl : Control, INamingContainer {
+#endif
static object abortTransaction = new object ();
static object commitTransaction = new object ();
static object error = new object ();
#region Properties
[EditorBrowsable (EditorBrowsableState.Never)]
+#if NET_2_0
+ [Obsolete]
+#endif
protected virtual int AutoHandlers {
get { return 0; }
set { }
public Control LoadControl (string virtualPath)
{
- object control = Activator.CreateInstance (GetTypeFromControlPath (virtualPath));
+#if NET_2_0
+ if (virtualPath == null)
+ throw new ArgumentNullException ("virtualPath");
+#else
+ if (virtualPath == null)
+ throw new HttpException ("virtualPath is null");
+#endif
+ Type type = GetTypeFromControlPath (virtualPath);
+ object [] attrs = type.GetCustomAttributes (typeof (PartialCachingAttribute), true);
+ if (attrs != null && attrs.Length == 1) {
+ PartialCachingAttribute attr = (PartialCachingAttribute) attrs [0];
+ PartialCachingControl ctrl = new PartialCachingControl (type);
+ ctrl.VaryByParams = attr.VaryByParams;
+ ctrl.VaryByControls = attr.VaryByControls;
+ ctrl.VaryByCustom = attr.VaryByCustom;
+ return ctrl;
+ }
+
+ object control = Activator.CreateInstance (type);
if (control is UserControl)
((UserControl) control).InitializeAsUserControl (Page);
public ITemplate LoadTemplate (string virtualPath)
{
+#if NET_2_0
+ if (virtualPath == null)
+ throw new ArgumentNullException ("virtualPath");
+#else
+ if (virtualPath == null)
+ throw new HttpException ("virtualPath is null");
+#endif
Type t = GetTypeFromControlPath (virtualPath);
return new SimpleTemplate (t);
}
[MonoTODO]
public Control ParseControl (string content)
{
+ if (content == null)
+ throw new ArgumentNullException ("content");
+
return null;
}
- [MonoTODO]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public
+#if !NET_2_0
+ static
+#endif
+ object ReadStringResource ()
+ {
+ throw new NotSupportedException ();
+ }
+
[EditorBrowsable (EditorBrowsableState.Never)]
public static object ReadStringResource (Type t)
{
- return null;
+ throw new NotSupportedException ();
}
[MonoTODO]
}
#if NET_2_0
-
- Stack dataItemCtx;
-
- internal void PushDataItemContext (object o)
- {
- if (dataItemCtx == null)
- dataItemCtx = new Stack ();
-
- dataItemCtx.Push (o);
- }
-
- internal void PopDataItemContext ()
- {
- if (dataItemCtx == null)
- throw new InvalidOperationException ();
-
- dataItemCtx.Pop ();
- }
-
- internal object CurrentDataItem {
- get {
- if (dataItemCtx == null || dataItemCtx.Count == 0)
- throw new InvalidOperationException ("No data item");
-
- return dataItemCtx.Peek ();
+ protected object Eval (string expression)
+ {
+ return DataBinder.Eval (Page.GetDataItem(), expression);
}
- }
-
- protected object Eval (string expression)
- {
- return DataBinder.Eval (CurrentDataItem, expression);
- }
- protected object Eval (string expression, string format)
- {
- return DataBinder.Eval (CurrentDataItem, expression, format);
- }
+ protected string Eval (string expression, string format)
+ {
+ return DataBinder.Eval (Page.GetDataItem(), expression, format);
+ }
- protected object XPath (string xpathexpression)
- {
- return XPathBinder.Eval (CurrentDataItem, xpathexpression);
- }
+ protected object XPath (string xpathexpression)
+ {
+ return XPathBinder.Eval (Page.GetDataItem(), xpathexpression);
+ }
- protected object XPath (string xpathexpression, string format)
- {
- return XPathBinder.Eval (CurrentDataItem, xpathexpression, format);
- }
+ protected string XPath (string xpathexpression, string format)
+ {
+ return XPathBinder.Eval (Page.GetDataItem(), xpathexpression, format);
+ }
- protected IEnumerable XPathSelect (string xpathexpression)
- {
- return XPathBinder.Select (CurrentDataItem, xpathexpression);
- }
-#endif
+ protected IEnumerable XPathSelect (string xpathexpression)
+ {
+ return XPathBinder.Select (Page.GetDataItem(), xpathexpression);
+ }
+
+ // IFilterResolutionService
+
+ [MonoTODO]
+ int IFilterResolutionService.CompareFilters (string filter1, string filter2)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ bool IFilterResolutionService.EvaluateFilter (string filterName)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
}
}