/// <summary> /// 格式化Cookie名称 /// </summary> /// <param name="name">Cookie名称</param> /// <returns>格式化后Cookie名称</returns> public unsafe static string FormatCookieName(string name) { if (string.IsNullOrEmpty(name)) { log.Error.Throw(log.exceptionType.Null); } if (name.Length > MaxCookieNameLength) log.Error.Throw(null, "cookie名称超过限定 " + ((uint)name.Length).toString(), false); fixed(char *nameFixed = name) { char *endName = nameFixed + name.Length; int count = unsafer.String.AsciiCount(nameFixed, endName, formatCookieNameCharMap.Map); if (*nameFixed == '$') { ++count; } if (count != 0) { string newName = fastCSharp.String.FastAllocateString(count = name.Length + (count << 1)); fixed(char *newNameFixed = newName) { char *nextCookieName = newNameFixed; if (*nameFixed == '$') { nextCookieName += 2; *(uint *)newNameFixed = '%' + ('2' << 16); *nextCookieName = '4'; } else { *nextCookieName = *nameFixed; } char *nextName = nameFixed; String.asciiMap formatMap = formatCookieNameCharMap; while (++nextName != endName) { uint nextValue = (uint)*nextName; if (formatMap.Get((int)nextValue)) { *++nextCookieName = '%'; *++nextCookieName = (char)numberExpand.ToHex(nextValue >> 4); *++nextCookieName = (char)numberExpand.ToHex(nextValue & 15); } else { *++nextCookieName = (char)nextValue; } } return(newName); } } } return(name); }
static connection() { if (config.sql.Default.CheckConnection.Length != 0) { checkConnectionAssemblyNameMap = new String.asciiMap(".,-", true); AppDomain.CurrentDomain.AssemblyLoad += checkConnection; threading.threadPool.TinyPool.FastStart(AppDomain.CurrentDomain.GetAssemblies(), thread.callType.CheckSqlConnectionArray); } }
/// <summary> /// 格式化Cookie名称 /// </summary> /// <param name="name">Cookie名称</param> /// <returns>格式化后Cookie名称</returns> public unsafe static string FormatCookieName(string name) { if (name.length() == 0) { log.Default.Throw(log.exceptionType.Null); } if (name.Length > MaxCookieNameLength) log.Default.Throw(null, "cookie名称超过限定 " + ((uint)name.Length).toString(), false); fixed(char *nameFixed = name) { char *endName = nameFixed + name.Length; int count = unsafer.String.asciiCount(nameFixed, endName, formatCookieNameCharMap.Map, FormatCookieNameChars[0]); if (*nameFixed == '$') { ++count; } if (count != 0) { char *nameChars = stackalloc char[count = name.Length + (count << 1)], nextCookieName = nameChars; if (*nameFixed == '$') { *nextCookieName++ = '%'; *(uint *)nextCookieName = '2' + ('4' << 16); nextCookieName += 2; } else { *nextCookieName = *nameFixed; } char * nextName = nameFixed; String.asciiMap formatMap = formatCookieNameCharMap; while (++nextName != endName) { int nextValue = (int)*nextName; if (formatMap.Get(nextValue)) { *++nextCookieName = '%'; int highValue = nextValue >> 4; *++nextCookieName = (char)(highValue < 10 ? highValue + '0' : (highValue + ('0' + 'A' - '9' - 1))); nextValue &= 15; *++nextCookieName = (char)(nextValue < 10 ? nextValue + '0' : (nextValue + ('0' + 'A' - '9' - 1))); } else { *++nextCookieName = (char)nextValue; } } return(new string(nameChars, 0, count)); } } return(name); }
static htmlNode() { int dataIndex = 0; pointer[] datas = unmanaged.Get(true , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes); spaceMap = new String.asciiMap(datas[dataIndex++], "\t\r\n ", true); spaceSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n >", true).Pointer; tagNameSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=>", true).Pointer; attributeSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=", true).Pointer; attributeNameSplitMap = new String.asciiMap(datas[dataIndex++], "\"'/>", true).Pointer; String.asciiMap tagNameAsciiMap = new String.asciiMap(tagNameMap = datas[dataIndex++], "!/", true); tagNameAsciiMap.Unsafer.Set('a', 26); tagNameAsciiMap.Unsafer.Set('A', 26); noLowerAttributeNames = new staticDictionary<string, string>(new string[] { "readOnly", "className" }, value => value.ToLower()); }