From: Argiris K. <be...@us...> - 2005-11-20 08:47:44
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3039/Core Modified Files: AjaxCallHelper.cs MagicAjaxModule.cs Log Message: Fixed the visibility issues and other bugs. Added AjaxCallEnd event for 'Session/Cache' page storing modes. Fixed some comments. Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AjaxCallHelper.cs 18 Nov 2005 18:53:07 -0000 1.6 --- AjaxCallHelper.cs 20 Nov 2005 08:47:29 -0000 1.7 *************** *** 53,59 **** public sealed class AjaxCallHelper { private AjaxCallHelper() { } ! private static System.Text.StringBuilder sbScript = null; #region Static Properties --- 53,73 ---- public sealed class AjaxCallHelper { + #region Private Fields/Methods private AjaxCallHelper() { } ! private static ArrayList _sbWritingLevels; ! private static int _writingLevel; ! ! private static void MergeNextWritingLevelRecursive (int writingLevel) ! { ! int nextLevel = writingLevel + 1; ! if (_sbWritingLevels.Count == nextLevel) ! return; ! ! MergeNextWritingLevelRecursive (nextLevel); ! (_sbWritingLevels[writingLevel] as StringBuilder).Append((_sbWritingLevels[nextLevel] as StringBuilder).ToString()); ! _sbWritingLevels.RemoveAt (nextLevel); ! } ! #endregion #region Static Properties *************** *** 81,85 **** get { ! return ( MagicAjaxModule.Instance.IsAjaxCall ); } } --- 95,99 ---- get { ! return ( HttpContext.Current != null && MagicAjaxModule.Instance.IsAjaxCall ); } } *************** *** 90,94 **** public static bool IsPageNoStoreMode { ! get { return (MagicAjaxModule.Instance.Configuration.PageStore.Mode == Configuration.PageStoreMode.NoStore); } } --- 104,108 ---- public static bool IsPageNoStoreMode { ! get { return ( HttpContext.Current != null && MagicAjaxModule.Instance.Configuration.PageStore.Mode == Configuration.PageStoreMode.NoStore ); } } *************** *** 117,121 **** get { ! return ( MagicAjaxModule.Instance.Form["__EVENTTARGET"] == "__AJAX_AjaxCallTimer" ); } } --- 131,135 ---- get { ! return ( MagicAjaxModule.Instance.Form["__EVENTTARGET"] == "__AJAX_AJAXCALLTIMER" ); } } *************** *** 173,178 **** #region Static Methods /// <summary> ! /// Determines if the page is being processed during an AjaxCall. /// </summary> /// <remarks> --- 187,246 ---- #region Static Methods + /// <summary> + /// Increases the script writing level. + /// </summary> + /// <remarks> + /// There must be a matching DecreaseWritingLevel call. + /// See remarks of MergeUpperWritingLevelsWithCurrent method. + /// </remarks> + public static void IncreaseWritingLevel() + { + _writingLevel++; + if (_writingLevel == _sbWritingLevels.Count) + _sbWritingLevels.Add (new StringBuilder()); + } + /// <summary> ! /// Decreases the script writing level. ! /// </summary> ! /// <remarks> ! /// There must be a matching IncreaseWritingLevel call. ! /// See remarks of MergeUpperWritingLevelsWithCurrent method. ! /// </remarks> ! public static void DecreaseWritingLevel() ! { ! if (_writingLevel == 0) ! throw new MagicAjaxException("Script writing level cannot be negative."); ! ! _writingLevel--; ! } ! ! /// <summary> ! /// Merges the script rendering from upper leves into the current one. ! /// </summary> ! /// <remarks> ! /// Writing levels are used to control the ordering of script commands, ! /// especially for recursive methods. ! /// For example: ! /// AjaxCallHelper.IncreaseWritingLevel(); ! /// WriteMyScript(); ! /// AjaxCallHelper.DecreaseWritingLevel(); ! /// ! /// AjaxCallHelper.Write("MyScript rendering will be after this"); ! /// AjaxCallHelper.MergeUpperWritingLevelsWithCurrent() ! /// ! /// This will produce the output: ! /// MyScript rendering will be after this ! /// [MyScript method rendering] ! /// </remarks> ! public static void MergeUpperWritingLevelsWithCurrent() ! { ! MergeNextWritingLevelRecursive(_writingLevel); ! } ! ! /// <summary> ! /// Determines if the page is being processed for an AjaxCall. It's more accurate ! /// than IsAjaxCall because it returns false if the page is being processed ! /// for Server.Transfer. /// </summary> /// <remarks> *************** *** 443,447 **** // Use the string builder //Response.Write (text + "\r\n"); ! sbScript.Append (text + "\r\n"); } --- 511,515 ---- // Use the string builder //Response.Write (text + "\r\n"); ! (_sbWritingLevels[_writingLevel] as StringBuilder).Append (text + "\r\n"); } *************** *** 452,456 **** hr.StatusDescription = "OK"; ! sbScript = new System.Text.StringBuilder(); } --- 520,526 ---- hr.StatusDescription = "OK"; ! _sbWritingLevels = new ArrayList(); ! _sbWritingLevels.Add (new StringBuilder()); ! _writingLevel = 0; } *************** *** 464,467 **** --- 534,540 ---- public static void End() { + if (_writingLevel > 0) + throw new MagicAjaxException("Script writing level should be 0 at the end of AjaxCall. IncreaseWritingLevel calls do not match DecreaseWritingLevel calls."); + WriteEndSignature(); *************** *** 469,473 **** hr.Clear(); ! hr.Write (sbScript.ToString()); MagicAjaxModule.Instance.CompletedAjaxCall = true; --- 542,547 ---- hr.Clear(); ! MergeNextWritingLevelRecursive (0); ! hr.Write ((_sbWritingLevels[0] as StringBuilder).ToString()); MagicAjaxModule.Instance.CompletedAjaxCall = true; Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MagicAjaxModule.cs 18 Nov 2005 19:59:41 -0000 1.17 --- MagicAjaxModule.cs 20 Nov 2005 08:47:29 -0000 1.18 *************** *** 701,704 **** --- 701,706 ---- InvokeScriptWriters (page); + + RaiseAjaxCallEventEnd (page); } *************** *** 740,743 **** --- 742,763 ---- /// <summary> + /// Raises AjaxCallEnd event on the supplied control and its children. + /// </summary> + /// <remarks> + /// This is a recursive method. It goes through the control collection tree + /// and raises the AjaxCallEnd event on all the controls that implement the + /// IAjaxCallEventHandler interface. + /// </remarks> + /// <param name="control"></param> + protected virtual void RaiseAjaxCallEventEnd (Control control) + { + if (control is IAjaxCallEventHandler) + ((IAjaxCallEventHandler) control).RaiseAjaxCallEndEvent(); + + for (int i=0; i < control.Controls.Count; i++) + RaiseAjaxCallEventEnd (control.Controls[i]); + } + + /// <summary> /// Raises the PreWriteScript event on the supplied control and its children. /// </summary> |