Author: igorz
Date: 2007-12-26 04:56:18 -0500 (Wed, 26 Dec 2007)
New Revision: 91889

Modified:
   trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
   trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManagerProxy.cs
Log:
fixed/redesigned ScriptManagerProxy

Modified: trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
===================================================================
--- trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs        
2007-12-26 00:47:20 UTC (rev 91888)
+++ trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs        
2007-12-26 09:56:18 UTC (rev 91889)
@@ -120,6 +120,7 @@
                bool _loadScriptsBeforeUI = true;
                AuthenticationServiceManager _authenticationService;
                ProfileServiceManager _profileService;
+               List<ScriptManagerProxy> _proxies;
 
                [DefaultValue (true)]
                [Category ("Behavior")]
@@ -538,9 +539,9 @@
 
                        if (!IsInAsyncPostBack) {
                                // Register Ajax framework script.
-                               RegisterScriptReference (ajaxScript, true);
+                               RegisterScriptReference (this, ajaxScript, 
true);
                                if (IsMultiForm) {
-                                       RegisterScriptReference 
(ajaxExtensionScript, true);
+                                       RegisterScriptReference (this, 
ajaxExtensionScript, true);
                                        RegisterClientScriptBlock (this, typeof 
(ScriptManager), "Sys.Application", 
"\nSys.Application._initialize(document.getElementById('" + Page.Form.ClientID 
+ "'));\n", true);
                                }
 
@@ -550,27 +551,29 @@
                                ScriptingProfileServiceSection profileService = 
(ScriptingProfileServiceSection) WebConfigurationManager.GetSection 
("system.web.extensions/scripting/webServices/profileService");
                                if (profileService.Enabled)
                                        sb.AppendLine 
("Sys.Services._ProfileService.DefaultWebServicePath = '" + ResolveClientUrl 
("~" + System.Web.Script.Services.ProfileService.DefaultWebServicePath) + "';");
-                               if (_profileService != null && 
!String.IsNullOrEmpty (_profileService.Path))
-                                       sb.AppendLine 
("Sys.Services.ProfileService.set_path('" + ResolveUrl (_profileService.Path) + 
"');");
+                               string profileServicePath = 
GetProfileServicePath ();
+                               if (!String.IsNullOrEmpty (profileServicePath))
+                                       sb.AppendLine 
("Sys.Services.ProfileService.set_path('" + profileServicePath + "');");
 
                                ScriptingAuthenticationServiceSection 
authenticationService = (ScriptingAuthenticationServiceSection) 
WebConfigurationManager.GetSection 
("system.web.extensions/scripting/webServices/authenticationService");
                                if (authenticationService.Enabled)
                                        sb.AppendLine 
("Sys.Services._AuthenticationService.DefaultWebServicePath = '" + 
ResolveClientUrl ("~/Authentication_JSON_AppService.axd") + "';");
-                               if (_authenticationService != null && 
!String.IsNullOrEmpty (_authenticationService.Path))
-                                       sb.AppendLine 
("Sys.Services.AuthenticationService.set_path('" + ResolveUrl 
(_authenticationService.Path) + "');");
+                               string authenticationServicePath = 
GetAuthenticationServicePath ();
+                               if (!String.IsNullOrEmpty 
(authenticationServicePath))
+                                       sb.AppendLine 
("Sys.Services.AuthenticationService.set_path('" + authenticationServicePath + 
"');");
 
                                RegisterClientScriptBlock (this, typeof 
(ScriptManager), "Framework", sb.ToString (), true);
 
-                               RegisterScriptReference (ajaxWebFormsScript, 
true);
+                               RegisterScriptReference (this, 
ajaxWebFormsScript, true);
 
                                if (IsMultiForm)
-                                       RegisterScriptReference 
(ajaxWebFormsExtensionScript, true);
+                                       RegisterScriptReference (this, 
ajaxWebFormsExtensionScript, true);
                        }
 
                        // Register Scripts
                        if (_scriptToRegister != null)
                                for (int i = 0; i < _scriptToRegister.Count; 
i++)
-                                       RegisterScriptReference 
(_scriptToRegister [i].ScriptReference, _scriptToRegister 
[i].LoadScriptsBeforeUI);
+                                       RegisterScriptReference 
(_scriptToRegister [i].Control, _scriptToRegister [i].ScriptReference, 
_scriptToRegister [i].LoadScriptsBeforeUI);
 
                        if (!IsInAsyncPostBack) {
                                // Register services
@@ -580,6 +583,15 @@
                                        }
                                }
 
+                               if (_proxies != null && _proxies.Count > 0) {
+                                       for (int i = 0; i < _proxies.Count; 
i++) {
+                                               ScriptManagerProxy proxy = 
_proxies [i];
+                                               for (int j = 0; j < 
proxy.Services.Count; j++) {
+                                                       
RegisterServiceReference (proxy.Services [j]);
+                                               }
+                                       }
+                               }
+
                                if (EnablePageMethods) {
                                        LogicalTypeInfo logicalTypeInfo = 
LogicalTypeInfo.GetLogicalTypeInfo (Page.GetType (), Page.Request.FilePath);
                                        RegisterClientScriptBlock (this, typeof 
(ScriptManager), "PageMethods", logicalTypeInfo.Proxy, true);
@@ -593,6 +605,28 @@
                        }
                }
 
+               string GetProfileServicePath () {
+                       if (_profileService != null && !String.IsNullOrEmpty 
(_profileService.Path))
+                               return ResolveClientUrl (_profileService.Path);
+
+                       if (_proxies != null && _proxies.Count > 0)
+                               for (int i = 0; i < _proxies.Count; i++)
+                                       if (!String.IsNullOrEmpty (_proxies 
[i].ProfileService.Path))
+                                               return _proxies 
[i].ResolveClientUrl (_proxies [i].ProfileService.Path);
+                       return null;
+               }
+
+               string GetAuthenticationServicePath () {
+                       if (_authenticationService != null && 
!String.IsNullOrEmpty (_authenticationService.Path))
+                               return ResolveClientUrl 
(_authenticationService.Path);
+
+                       if (_proxies != null && _proxies.Count > 0)
+                               for (int i = 0; i < _proxies.Count; i++)
+                                       if (!String.IsNullOrEmpty (_proxies 
[i].AuthenticationService.Path))
+                                               return _proxies 
[i].ResolveClientUrl (_proxies [i].AuthenticationService.Path);
+                       return null;
+               }
+
 #if TARGET_J2EE
                bool IsMultiForm {
                        get {
@@ -626,6 +660,14 @@
                                }
                        }
 
+                       if (_proxies != null && _proxies.Count > 0) {
+                               for (int i = 0; i < _proxies.Count; i++) {
+                                       ScriptManagerProxy proxy = _proxies [i];
+                                       for (int j = 0; j < 
proxy.Scripts.Count; j++)
+                                               yield return new 
ScriptReferenceEntry (proxy, proxy.Scripts [j], LoadScriptsBeforeUI);
+                               }
+                       }
+
                        if (_registeredScriptControls != null && 
_registeredScriptControls.Count > 0) {
                                for (int i = 0; i < 
_registeredScriptControls.Count; i++) {
                                        IEnumerable<ScriptReference> scripts = 
_registeredScriptControls [i].GetScriptReferences ();
@@ -720,12 +762,12 @@
                        RegisterClientScriptInclude (page, type, "resource-" + 
resourceName, ScriptResourceHandler.GetResourceUrl (type.Assembly, 
resourceName, true));
                }
 
-               void RegisterScriptReference (ScriptReference script, bool 
loadScriptsBeforeUI) {
+               void RegisterScriptReference (Control control, ScriptReference 
script, bool loadScriptsBeforeUI) {
 
                        bool isDebugMode = IsDeploymentRetail ? false : 
(script.ScriptModeInternal == ScriptMode.Inherit ? IsDebuggingEnabled : 
(script.ScriptModeInternal == ScriptMode.Debug));
                        string url;
                        if (!String.IsNullOrEmpty (script.Path)) {
-                               url = GetScriptName (ResolveClientUrl 
(script.Path), isDebugMode, EnableScriptLocalization ? 
script.ResourceUICultures : null);
+                               url = GetScriptName (control.ResolveClientUrl 
(script.Path), isDebugMode, EnableScriptLocalization ? 
script.ResourceUICultures : null);
                        }
                        else if (!String.IsNullOrEmpty (script.Name)) {
                                Assembly assembly;
@@ -1531,5 +1573,12 @@
                                _script = script;
                        }
                }
+
+               internal void RegisterProxy (ScriptManagerProxy 
scriptManagerProxy) {
+                       if (_proxies == null)
+                               _proxies = new List<ScriptManagerProxy> ();
+
+                       _proxies.Add (scriptManagerProxy);
+               }
        }
 }

Modified: 
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManagerProxy.cs
===================================================================
--- trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManagerProxy.cs   
2007-12-26 00:47:20 UTC (rev 91888)
+++ trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManagerProxy.cs   
2007-12-26 09:56:18 UTC (rev 91889)
@@ -41,6 +41,10 @@
        public class ScriptManagerProxy : Control
        {
                ScriptManager _scriptManager;
+               ScriptReferenceCollection _scripts;
+               ServiceReferenceCollection _services;
+               AuthenticationServiceManager _authenticationService;
+               ProfileServiceManager _profileService;
 
                [Category ("Behavior")]
                [MergableProperty (false)]
@@ -48,7 +52,9 @@
                [PersistenceMode (PersistenceMode.InnerProperty)]
                public AuthenticationServiceManager AuthenticationService {
                        get {
-                               return ScriptManager.AuthenticationService;
+                               if (_authenticationService == null)
+                                       _authenticationService = new 
AuthenticationServiceManager ();
+                               return _authenticationService;
                        }
                }
 
@@ -58,7 +64,9 @@
                [PersistenceMode (PersistenceMode.InnerProperty)]
                public ProfileServiceManager ProfileService {
                        get {
-                               return ScriptManager.ProfileService;
+                               if (_profileService == null)
+                                       _profileService = new 
ProfileServiceManager ();
+                               return _profileService;
                        }
                }
 
@@ -67,7 +75,10 @@
                [MergableProperty (false)]
                public ScriptReferenceCollection Scripts {
                        get {
-                               return ScriptManager.Scripts;
+                               if (_scripts == null)
+                                       _scripts = new 
ScriptReferenceCollection ();
+
+                               return _scripts;
                        }
                }
 
@@ -76,7 +87,10 @@
                [Category ("Behavior")]
                public ServiceReferenceCollection Services {
                        get {
-                               return ScriptManager.Services;
+                               if (_services == null)
+                                       _services = new 
ServiceReferenceCollection ();
+
+                               return _services;
                        }
                }
 
@@ -105,6 +119,7 @@
 
                protected override void OnInit (EventArgs e) {
                        base.OnInit (e);
+                       ScriptManager.RegisterProxy (this);
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to