2009-11-23 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web / BrowserCapabilities.cs
index 2b02461d64d50f3176652ad55d42822d3f2c1790..c75f572a2e9455a29277ef4b2a770cbb81364e3a 100644 (file)
@@ -5,7 +5,7 @@
 //   Patrik Torstensson (Patrik.Torstensson@labs2.com)
 //   Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //
-// (c) 2003 Novell, Inc. (http://www.novell.com)
+// (c) 2003-2009 Novell, Inc. (http://www.novell.com)
 //
 
 //
@@ -34,17 +34,11 @@ using System.Globalization;
 using System.Web.Configuration;
 using System.Web.UI;
 using System.Security.Permissions;
+using System.Web.Util;
 
-#if NET_2_0
-namespace System.Web.Configuration {
+namespace System.Web.Configuration
+{
        public partial class HttpCapabilitiesBase
-#else
-
-namespace System.Web {
-       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
-       [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
-       public class HttpBrowserCapabilities : HttpCapabilitiesBase
-#endif
        {
                const int HaveActiveXControls = 1; // 1;
                const int HaveAdapters = 2;
@@ -150,7 +144,7 @@ namespace System.Web {
                const int HaveSupportsUncheck = 102;
                const int HaveSupportsXmlHttp = 103;
                const int HaveTables = 104; // 18;
-               //const int HaveTagWriter = 105; // 19;
+               const int HaveTagWriter = 105; // 19;
                const int HaveType = 106;
                const int HaveUseOptimizedCacheKey = 107;
                const int HaveVBScript = 108; // 20;
@@ -179,7 +173,7 @@ namespace System.Web {
                Version msDomVersion;
                string platform;
                bool tables;
-               //Type tagWriter;
+               Type tagWriter;
                bool vbscript;
                string version;
                Version w3CDomVersion;
@@ -188,12 +182,6 @@ namespace System.Web {
                Version [] clrVersions;
                internal string useragent;
 
-#if !NET_2_0
-               public HttpBrowserCapabilities ()
-               {
-               }
-#endif
-
                public bool ActiveXControls {
                        get {
                                if (!Get (HaveActiveXControls)) {
@@ -250,7 +238,7 @@ namespace System.Web {
                                return browser;
                        }
                }
-#if NET_2_0
+
                ArrayList browsers = null;
                public ArrayList Browsers {
                        get {
@@ -266,16 +254,16 @@ namespace System.Web {
                public bool IsBrowser (string browserName) 
                {
                        foreach (string browser in Browsers) {
-                               if (0 == String.CompareOrdinal(browser, "Unknown")) {
+                               if (0 == String.Compare (browser, "Unknown", StringComparison.OrdinalIgnoreCase)) {
                                        continue;
                                }
-                               if (0 == String.CompareOrdinal(browserName, browser)) {
+                               if (0 == String.Compare (browserName, browser, StringComparison.OrdinalIgnoreCase)) {
                                        return true;
                                }
                        }
                        return false;
                }
-#endif
+
                public bool CDF {
                        get {
                                if (!Get (HaveCDF)) {
@@ -351,9 +339,8 @@ namespace System.Web {
                        }
                }
 
-#if NET_2_0
+
                [Obsolete]
-#endif
                public bool JavaScript {
                        get {
                                if (!Get (HaveJavaScript)) {
@@ -422,9 +409,18 @@ namespace System.Web {
 
                public Type TagWriter {
                        get {
-                               return typeof (HtmlTextWriter);
+                               if (!Get (HaveTagWriter)) {
+                                       tagWriter = GetTagWriter ();
+                                       Set (HaveTagWriter);
+                               }
+                               return tagWriter;
                        }
                }
+               
+               internal virtual Type GetTagWriter ()
+               {
+                               return typeof (HtmlTextWriter);                 
+               }
 
                public string Type {
                        get {
@@ -489,7 +485,6 @@ namespace System.Web {
                        }
                }
 
-#if NET_1_1
                public Version [] GetClrVersions ()
                {
                        if (clrVersions == null)
@@ -497,7 +492,6 @@ namespace System.Web {
 
                        return clrVersions;
                }
-#endif
 
                void InternalGetClrVersions ()
                {
@@ -527,11 +521,7 @@ namespace System.Web {
                        
                        if (list == null || list.Count == 0) {
                                clrVersion = new Version ();
-#if NET_2_0
                                clrVersions = null;
-#else
-                               clrVersions = new Version [1] { clrVersion };
-#endif
                        } else {
                                list.Sort ();
                                clrVersions = (Version []) list.ToArray (typeof (Version));
@@ -545,7 +535,7 @@ namespace System.Web {
                                throw CreateCapabilityNotFoundException (key);
                        }
 
-                       return (String.Compare (v, "True", true, CultureInfo.InvariantCulture) == 0);
+                       return (String.Compare (v, "True", true, Helpers.InvariantCulture) == 0);
                }
 
                int ReadInt32 (string key)
@@ -576,7 +566,7 @@ namespace System.Web {
                        }
                }
 
-               private string ReadString (string key) 
+               string ReadString (string key) 
                {
                        string v = this [key];
                        if (v == null) {
@@ -601,8 +591,7 @@ namespace System.Web {
                        }
                }
 
-#if NET_2_0
-               private ArrayList ReadArrayList (string key) 
+               ArrayList ReadArrayList (string key) 
                {
                        ArrayList v = (ArrayList)this.capabilities [key];
                        if (v == null) {
@@ -611,7 +600,7 @@ namespace System.Web {
 
                        return v;
                }
-#endif
+
                Exception CreateCapabilityNotFoundException (string key) {
                        return new ArgumentNullException (String.Format ("browscaps.ini does not contain a definition for capability {0} for userAgent {1}", key, Browser));
                }