From: Argiris K. <be...@us...> - 2005-12-21 00:40:31
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21640/Core Modified Files: MagicAjaxModule.cs Util.cs Log Message: Moved all RegExs to Util.cs as static objects. Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Util.cs 20 Dec 2005 22:48:12 -0000 1.17 --- Util.cs 21 Dec 2005 00:40:23 -0000 1.18 *************** *** 38,41 **** --- 38,49 ---- public const string FormElementPattern = @"<(?<tag>input|textarea|select)\s+(?<attribute>(?<attrname>[-\w]+)=((""|')(?<attrvalue>.*?)(""|')\s*|(?<attrvalue>[-\w]+)\s*))*.*?(/>|>(?<inner>.*?)</\k'tag'>)"; + #region Global Regular Expressions + private static RegexOptions _options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture; + public static Regex FormElementRegEx = new Regex(Util.FormElementPattern, _options); + public static Regex FormElementOptionsRegEx = new Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", _options); + public static Regex FormElementOptionSelectedRegEx = new Regex(@"<option.*?(?<selected>selected=(""|'|)selected(""|'|)(\s+|(?=>))).*?>", _options); + public static Regex ScriptPatternRegEx = new Regex(Util.ScriptPattern, RegexOptions.IgnoreCase); + #endregion + /// <summary> /// Add 'defer' attribute to script tags excluding external script files. *************** *** 53,57 **** StringBuilder sb = new StringBuilder(html); ! Regex regEx = MagicAjaxModule.ScriptPattern; MatchCollection scriptMatches = regEx.Matches(html); //MatchCollection scriptMatches = Regex.Matches(html, ScriptPattern, RegexOptions.IgnoreCase); --- 61,65 ---- StringBuilder sb = new StringBuilder(html); ! Regex regEx = Util.ScriptPatternRegEx; MatchCollection scriptMatches = regEx.Matches(html); //MatchCollection scriptMatches = Regex.Matches(html, ScriptPattern, RegexOptions.IgnoreCase); *************** *** 115,119 **** { StringBuilder strbuild = new StringBuilder(html); ! Regex regEx = MagicAjaxModule.FormElementOptionsRegEx; MatchCollection matches = regEx.Matches(html); int diff = 0; --- 123,127 ---- { StringBuilder strbuild = new StringBuilder(html); ! Regex regEx = Util.FormElementRegEx; MatchCollection matches = regEx.Matches(html); int diff = 0; *************** *** 200,204 **** case "select": Group selInner = match.Groups["inner"]; ! Regex regExOpt = MagicAjaxModule.FormElementOptionSelectedRegEx; //now remove the 'selected' attributes within this <select> tag --- 208,212 ---- case "select": Group selInner = match.Groups["inner"]; ! Regex regExOpt = Util.FormElementOptionSelectedRegEx; //now remove the 'selected' attributes within this <select> tag Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** MagicAjaxModule.cs 20 Dec 2005 23:51:40 -0000 1.45 --- MagicAjaxModule.cs 21 Dec 2005 00:40:23 -0000 1.46 *************** *** 61,90 **** private MagicAjaxContext _magicAjaxContext; - #region Global Regular Expressions - private static RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture; - private Regex _formElementRegEx = new Regex(Util.FormElementPattern, options); - private Regex _formElementOptionsRegEx = new Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); - private Regex _formElementOptionSelectedRegEx = new Regex(@"<option.*?(?<selected>selected=(""|'|)selected(""|'|)(\s+|(?=>))).*?>", options); - private Regex _scriptPattern = new Regex(Util.ScriptPattern, RegexOptions.IgnoreCase); - - public static Regex FormElementRegEx - { - get { return (Regex)HttpContext.Current.Items["FormElementRegEx"]; } - } - public static Regex FormElementOptionsRegEx - { - get { return (Regex)HttpContext.Current.Items["FormElementOptionsRegEx"]; } - } - public static Regex FormElementOptionSelectedRegEx - { - get { return (Regex)HttpContext.Current.Items["FormElementOptionSelectedRegEx"]; } - } - public static Regex ScriptPattern - { - get { return (Regex)HttpContext.Current.Items["ScriptPattern"]; } - } - - #endregion - #region IHttpModule implementation /// <summary> --- 61,64 ---- *************** *** 425,434 **** _response = context.Response; - // Init global Regular Expressions - context.Items.Add("FormElementRegEx", _formElementRegEx); - context.Items.Add("FormElementOptionsRegEx", _formElementOptionsRegEx); - context.Items.Add("FormElementOptionSelectedRegEx", _formElementOptionSelectedRegEx); - context.Items.Add("ScriptPattern", _scriptPattern); - // Create a new context and add it to the items collection for later retrieval // by MagicAjaxContext.Current --- 399,402 ---- |