This commit introduces a few 4.0 rendering changes which break some tests. The...
[mono.git] / mcs / class / System.Web / System.Web.UI / BasePartialCachingControl.cs
index 3debb830b332898ff6073c03616e521d470469b7..39f359bd76fb2e56ffe0473caaba40c83be7faab 100644 (file)
@@ -43,15 +43,18 @@ namespace System.Web.UI
        [ToolboxItem (false)]
        public abstract class BasePartialCachingControl : Control
        {
-               private CacheDependency dependency;
-               private string ctrl_id;
-               private string guid;
-               private int duration;
-               private string varyby_params;
-               private string varyby_controls;
-               private string varyby_custom;
-
-               private Control control;
+               CacheDependency dependency;
+               string ctrl_id;
+               string guid;
+               int duration;
+               string varyby_params;
+               string varyby_controls;
+               string varyby_custom;
+               DateTime expirationTime;
+               bool slidingExpiration;
+               
+               Control control;
+               ControlCachePolicy cachePolicy;
                
                protected BasePartialCachingControl()
                {
@@ -87,6 +90,16 @@ namespace System.Web.UI
                        set { varyby_custom = value; }
                }
 
+               internal DateTime ExpirationTime {
+                       get { return expirationTime; }
+                       set { expirationTime = value; }
+               }
+
+               internal bool SlidingExpiration {
+                       get { return slidingExpiration; }
+                       set { slidingExpiration = value; }
+               }
+               
                internal abstract Control CreateControl ();
 
                public override void Dispose ()
@@ -97,25 +110,15 @@ namespace System.Web.UI
                        }
                }
 
-#if NET_2_0
-               protected internal
-#else
-               protected
-#endif
-               override void OnInit (EventArgs e)
+               protected internal override void OnInit (EventArgs e)
                {
                        control = CreateControl ();
                        Controls.Add (control);
                }
 
-#if NET_2_0
-               protected internal
-#else
-               protected
-#endif
-               override void Render (HtmlTextWriter output)
+               protected internal override void Render (HtmlTextWriter output)
                {
-                       Cache cache = HttpRuntime.Cache;
+                       Cache cache = HttpRuntime.InternalCache;
                        string key = CreateKey ();
                        string data = cache [key] as string;
 
@@ -137,27 +140,28 @@ namespace System.Web.UI
                                output.Write (text);
                        }
 
-                       context.Cache.InsertPrivate (key, text, dependency,
-                                               DateTime.Now.AddSeconds (duration),
-                                               Cache.NoSlidingExpiration,
-                                               CacheItemPriority.Normal, null);
+                       context.InternalCache.Insert (key, text, dependency,
+                                                     DateTime.Now.AddSeconds (duration),
+                                                     Cache.NoSlidingExpiration,
+                                                     CacheItemPriority.Normal, null);
                }
 
-#if NET_2_0
                public ControlCachePolicy CachePolicy 
                {
                        get {
-                               throw new NotImplementedException ();
+                               if (cachePolicy == null)
+                                       cachePolicy = new ControlCachePolicy (this);
+
+                               return cachePolicy;
                        }
                }
-#endif
 
                public CacheDependency Dependency {
                        get {return dependency;}
                        set {dependency = value;}
                }
 
-               private string CreateKey ()
+               string CreateKey ()
                {
                        StringBuilder builder = new StringBuilder ();
                        HttpContext context = HttpContext.Current;