One more changelog
[mono.git] / mcs / class / System.Web / System.Web.UI / PageParser.cs
index b1574d476b3d5f0662f88bd60a9a7dd1d0e1d5a1..0703b24f193e07baa0748c16e5afb647f4b81626 100644 (file)
@@ -35,6 +35,7 @@ using System.Text;
 using System.Web.Compilation;
 using System.Web.Configuration;
 using System.Web.Util;
+using System.IO;
 
 namespace System.Web.UI
 {
@@ -62,6 +63,10 @@ namespace System.Web.UI
 #if NET_2_0
                string masterPage;
                Type masterType;
+               string title;
+               string theme;
+               string styleSheetTheme;
+               bool enable_event_validation;
 #endif
 
                public PageParser ()
@@ -77,6 +82,17 @@ namespace System.Web.UI
                        AddApplicationAssembly ();
                }
 
+#if NET_2_0
+               internal PageParser (string virtualPath, TextReader reader, HttpContext context)
+               {
+                       Context = context;
+                       BaseVirtualDir = UrlUtils.GetDirectory (virtualPath);
+                       Reader = reader;
+                       SetBaseType (PagesConfig.PageBaseType);
+                       AddApplicationAssembly ();
+               }
+#endif
+
                public static IHttpHandler GetCompiledPageInstance (string virtualPath,
                                                                    string inputFile, 
                                                                    HttpContext context)
@@ -85,10 +101,16 @@ namespace System.Web.UI
                        IHttpHandler h = (IHttpHandler) pp.GetCompiledInstance ();
                        return h;
                }
-
+               
                internal override void ProcessMainAttributes (Hashtable atts)
                {
-                       string enabless = GetString (atts, "EnableSessionState", PagesConfig.EnableSessionState);
+                       string enabless = GetString (atts, "EnableSessionState",
+#if NET_2_0
+                                                    PagesConfig.EnableSessionState.ToString()
+#else
+                                                    PagesConfig.EnableSessionState
+#endif
+                                                    );
                        if (enabless != null) {
                                readonlySessionState = (String.Compare (enabless, "readonly", true) == 0);
                                if (readonlySessionState == true || String.Compare (enabless, "true", true) == 0) {
@@ -169,12 +191,15 @@ namespace System.Web.UI
                                
                                CultureInfo ci = null;
                                try {
-                                       ci = new CultureInfo (culture);                                 
+#if NET_2_0
+                                       if (!culture.StartsWith ("auto"))
+#endif
+                                               ci = new CultureInfo (culture);
                                } catch {
                                        ThrowParseException ("Unsupported Culture: " + culture);
                                }
 
-                               if (ci.IsNeutralCulture) {
+                               if (ci != null && ci.IsNeutralCulture) {
                                        string suggestedCulture = SuggestCulture (culture);
                                        string fmt = "Culture attribute must be set to a non-neutral Culture.";
                                        if (suggestedCulture != null)
@@ -189,12 +214,15 @@ namespace System.Web.UI
                        if (uiculture != null) {
                                CultureInfo ci = null;
                                try {
-                                       ci = new CultureInfo (uiculture);                                       
+#if NET_2_0
+                                       if (!uiculture.StartsWith ("auto"))
+#endif
+                                               ci = new CultureInfo (uiculture);
                                } catch {
                                        ThrowParseException ("Unsupported Culture: " + uiculture);
                                }
 
-                               if (ci.IsNeutralCulture) {
+                               if (ci != null && ci.IsNeutralCulture) {
                                        string suggestedCulture = SuggestCulture (uiculture);
                                        string fmt = "UICulture attribute must be set to a non-neutral Culture.";
                                        if (suggestedCulture != null)
@@ -230,6 +258,16 @@ namespace System.Web.UI
                        validateRequest = GetBool (atts, "ValidateRequest", PagesConfig.ValidateRequest);
                        clientTarget = GetString (atts, "ClientTarget", null);
                        if (clientTarget != null) {
+#if NET_2_0
+                               ClientTargetSection sec = (ClientTargetSection)WebConfigurationManager.GetSection ("system.web/clientTarget");
+                               if (sec.ClientTargets[clientTarget] == null) {
+                                       ThrowParseException (String.Format (
+                                                       "ClientTarget '{0}' is an invalid alias. See the " +
+                                                       "documentation for <clientTarget> config. section.",
+                                                       clientTarget));
+                               }
+                               clientTarget = sec.ClientTargets[clientTarget].UserAgent;
+#else
                                NameValueCollection coll;
                                coll = (NameValueCollection) Context.GetConfig ("system.web/clientTarget");
                                if (coll == null || coll [clientTarget] == null) {
@@ -239,6 +277,7 @@ namespace System.Web.UI
                                                        clientTarget));
                                }
                                clientTarget = (string) coll [clientTarget];
+#endif
                        }
 
                        notBuffer = !GetBool (atts, "Buffer", true);
@@ -249,6 +288,12 @@ namespace System.Web.UI
                        // Make sure the page exists
                        if (masterPage != null)
                                MasterPageParser.GetCompiledMasterType (masterPage, MapPath (masterPage), HttpContext.Current);
+
+                       title = GetString(atts, "Title", null);
+
+                       theme = GetString (atts, "Theme", null);
+                       styleSheetTheme = GetString (atts, "StyleSheetTheme", null);
+                       enable_event_validation = GetBool (atts, "EnableEventValidation", true);
 #endif
                        // Ignored by now
                        GetString (atts, "EnableViewStateMac", null);
@@ -369,6 +414,14 @@ namespace System.Web.UI
                }
 
 #if NET_2_0
+               internal string Theme {
+                       get { return theme; }
+               }
+
+               internal string StyleSheetTheme {
+                       get { return styleSheetTheme; }
+               }
+
                internal string MasterPageFile {
                        get { return masterPage; }
                }
@@ -376,6 +429,14 @@ namespace System.Web.UI
                internal Type MasterType {
                        get { return masterType; }
                }
+
+               internal string Title {
+                       get { return title; }
+               }
+
+               internal bool EnableEventValidation {
+                       get { return enable_event_validation; }
+               }
 #endif
        }
 }