2005-10-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 25 Oct 2005 16:35:24 +0000 (16:35 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 25 Oct 2005 16:35:24 +0000 (16:35 -0000)
* TemplateControl.cs:
* PartialCachingControl.cs: if a control is cacheable, LoadControl
returns a PartialCachingControl that holds the VaryBy* and takes care
of partial caching and rendering. Fixes bug #76547.

svn path=/trunk/mcs/; revision=52188

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/PartialCachingControl.cs
mcs/class/System.Web/System.Web.UI/TemplateControl.cs

index 68d0f60b98bc4fb6d38b5ee5927a1738ad47ce1c..754b07b6fc2db88857ae12a8d58f692e7b9aec4c 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * TemplateControl.cs:
+       * PartialCachingControl.cs: if a control is cacheable, LoadControl
+       returns a PartialCachingControl that holds the VaryBy* and takes care
+       of partial caching and rendering. Fixes bug #76547.
+
 2005-10-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Page.cs: don't cache the 'Validate()' results. IsValid retests
index 850e37906a19f47e10bcb6c33e04101e8b3c43a6..6ffbfe861310befa6013f615d2df68cf8451d54a 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //
 // (C) 2003 Andreas Nahr
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
@@ -37,24 +38,27 @@ namespace System.Web.UI {
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        public class PartialCachingControl : BasePartialCachingControl
        {
+               Type type;
+               Control control;
 
-               //private Type controlType;
-               private Control createdControl;
-
-               internal PartialCachingControl (Type createCachedControlType)
+               internal PartialCachingControl (Type type)
                {
-               //      controlType = createCachedControlType;
+                       this.type = type;
+
                }
 
-               [MonoTODO ("Implement")]
-               internal override Control CreateControl()
+               internal override Control CreateControl ()
                {
-                       createdControl = null;
-                       throw new NotImplementedException ();
+                       control = (Control) Activator.CreateInstance (type);
+                       if (control is UserControl)
+                               ((UserControl) control).InitializeAsUserControl (Page);
+
+                       return control;
                }
 
                public Control CachedControl {
-                       get {return createdControl;
+                       get { return control; 
                }
        }
 }
+
index 7a896b9b8a66ef54ab4b5af1c9ca4905b067e783..6c629e05363228771cabb163513514f9b596f637 100644 (file)
@@ -169,7 +169,18 @@ namespace System.Web.UI {
                        if (virtualPath == null)
                                throw new HttpException ("virtualPath is null");
 #endif
-                       object control = Activator.CreateInstance (GetTypeFromControlPath (virtualPath));
+                       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);