private static bool IsCompressed(System.Web.UI.ScriptReference objRef) { if (objRef.ScriptMode == System.Web.UI.ScriptMode.Debug) { return(false); } else { return(true); } }
private static bool HashMatch(System.Web.UI.ScriptManager objScriptManager) { //General.Debug.Trace("Starting Hash Match"); string strPage = GetPageKey(objScriptManager); string strTargetFile = objScriptManager.Page.MapPath("Scripts/Compiled/" + strPage + ".js"); string strData = File.ReadAllText(strTargetFile); strData = StringFunctions.AllBetween(strData, "<HASH>", "</HASH>"); if (StringFunctions.IsNullOrWhiteSpace(strData)) { return(false); } string[] aryHashKeys = strData.Split(','); if (aryHashKeys.Length != objScriptManager.Scripts.Count) { return(false); } foreach (string strHashKey in aryHashKeys) { string[] aryTemp = strHashKey.Split(':'); string strFile = aryTemp[0]; if (!AlwaysCompress) { System.Web.UI.ScriptReference objRef = FindScriptReference(strFile, objScriptManager); if (objRef == null) { return(false); } bool blnCompressed = General.Data.SqlConvert.ToBoolean(aryTemp[2]); if (blnCompressed != IsCompressed(strFile, objScriptManager)) { return(false); } } string strOldHash = aryTemp[1]; string strNewHash = GetHashString(objScriptManager.Page.MapPath(strFile)); if (strOldHash != strNewHash) { return(false); } } //General.Debug.Trace("Finished Hash Match"); return(true); }