private static String checkPathVar(VarLabel varLabel, String ret) { if (strUtil.IsNullOrEmpty(ret)) { return(ret); } if (varLabel.Prefix == "~" || varLabel.Prefix == "~/") { //if (ret.StartsWith( "/" )) { // ret = ret.TrimStart( '/' ); //} // ~img/,~js/, ~static/...只允许26个英文字母 for (int i = 0; i < ret.Length; i++) { if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf(ret[i]) < 0) { return(null); } } return(ret); } return(ret); }
private static Boolean getIsStartWithPrefix(VarLabel varLabel, char[] charList, int index) { for (int i = 0; i < varLabel.Prefix.Length; i++) { if (charList[index + i] != varLabel.Prefix[i]) { return(false); } } return(true); }
private static String getStringToCheck(VarLabel varLabel, int index, char[] charList) { String strToCheck = ""; int maxLength = getCheckMaxLength(varLabel); for (int i = varLabel.Prefix.Length; i < maxLength; i++) { if (index + i > charList.Length - 1) { break; } strToCheck += charList[index + i]; } return(strToCheck); }
private static String getMatchedVarName(VarLabel varLabel, int index, char[] charList) { // 1、是否以prefix开头 Boolean isStartWithPrefix = getIsStartWithPrefix(varLabel, charList, index); if (!isStartWithPrefix) { return(null); } // 2、是否以postfix结尾 String strToCheck = getStringToCheck(varLabel, index, charList); int postfixIndex = strToCheck.IndexOf(varLabel.Postfix); if (postfixIndex >= 0) { // 注意,这里可能返回String.Empty return(strToCheck.Substring(0, postfixIndex)); } return(null); }
private static String getStringToCheck( VarLabel varLabel, int index, char[] charList ) { String strToCheck = ""; int maxLength = getCheckMaxLength( varLabel ); for (int i = varLabel.Prefix.Length; i < maxLength; i++) { if (index + i > charList.Length - 1) break; strToCheck += charList[index + i]; } return strToCheck; }
private static String getMatchedVarName( VarLabel varLabel, int index, char[] charList ) { // 1、是否以prefix开头 Boolean isStartWithPrefix = getIsStartWithPrefix( varLabel, charList, index ); if (!isStartWithPrefix) return null; // 2、是否以postfix结尾 String strToCheck = getStringToCheck( varLabel, index, charList ); int postfixIndex = strToCheck.IndexOf( varLabel.Postfix ); if (postfixIndex >= 0) { // 注意,这里可能返回String.Empty return strToCheck.Substring( 0, postfixIndex ); } return null; }
private static Boolean getIsStartWithPrefix( VarLabel varLabel, char[] charList, int index ) { for (int i = 0; i < varLabel.Prefix.Length; i++) { if (charList[index + i] != varLabel.Prefix[i]) return false; } return true; }
private static int getCheckMaxLength( VarLabel varLabel ) { return varLabel.Prefix.Length + 50; }
private static int getCheckMaxLength(VarLabel varLabel) { return(varLabel.Prefix.Length + 50); }
private static String checkPathVar( VarLabel varLabel, String ret ) { if (strUtil.IsNullOrEmpty( ret )) return ret; if (varLabel.Prefix == "~" || varLabel.Prefix == "~/") { //if (ret.StartsWith( "/" )) { // ret = ret.TrimStart( '/' ); //} // ~img/,~js/, ~static/...只允许26个英文字母 for (int i = 0; i < ret.Length; i++) { if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf( ret[i] ) < 0) { return null; } } return ret; } return ret; }