/// <summary> /// 根据枚举字符串查找目标索引 /// </summary> /// <param name="jsonDeSerializer">JSON 解析器</param> /// <param name="value">当前字符</param> /// <returns>目标索引,null返回-1</returns> private int flagEnum(JsonDeSerializer jsonDeSerializer, char value) { byte *currentState = State; do { char *prefix = (char *)(currentState + *(int *)currentState); if (*prefix != 0) { if (value != *prefix) { return(-1); } while (*++prefix != 0) { if (jsonDeSerializer.NextEnumChar() != *prefix) { return(-1); } } value = jsonDeSerializer.NextEnumChar(); } if (value == 0 || value == ',') { return(jsonDeSerializer.DeSerializeState == DeSerializeState.Success ? *(int *)(currentState + sizeof(int) * 2) : -1); } if (*(int *)(currentState + sizeof(int)) == 0) { return(-1); } int index = value < 128 ? (int)*(ushort *)(charsAscii + (value << 1)) : getCharIndex(value); byte *table = currentState + *(int *)(currentState + sizeof(int)); if (tableType == 0) { if ((index = *(table + index)) == 0) { return(-1); } currentState = State + index * 3 * sizeof(int); } else if (tableType == 1) { if ((index = (int)*(ushort *)(table + index * sizeof(ushort))) == 0) { return(-1); } currentState = State + index * 3 * sizeof(int); } else { if ((index = *(int *)(table + index * sizeof(int))) == 0) { return(-1); } currentState = State + index; } value = jsonDeSerializer.NextEnumChar(); }while (true); }