/// <summary> /// Does this entry match the request /// </summary> /// <param name="request">The request</param> /// <returns>True if it matches</returns> public bool IsMatch(HttpRequestHeader request) { bool ret = true; if (request != null) { if (!PathMatch.IsMatch(request.Path)) { ret = false; } if (MethodMatch.IsMatch(request.Method)) { ret = false; } } return(ret); }
private int ParseObject(string json, int offset, bool parentPathMatched) { int i = offset; int length = json.Length; int fields = 0; if (json[i] != '{') { throw new JsonParseException("Invalid object"); } for (i++; i < length;) { if (json[i] == '}') { break; } else if (IsWhiteSpace(json[i])) { i++; } else { if (fields > 0) { if (json[i++] != ',') { throw new JsonParseException("Invalid object; missing field delimiter"); } if (i == length) { throw new JsonParseException("Invalid object; unexpected end of input"); } while (i < length && IsWhiteSpace(json[i])) { i++; } if (i == length) { throw new JsonParseException("Invalid object; unexpected end of input"); } if (json[i] == '}') { i++; break; } } var objectStartIndex = i; JsonString name; i = ParseString(json, i, out name); if (i == length) { throw new JsonParseException("Invalid object; missing value"); } pathStack.Push(name); bool pathMatched = !parentPathMatched && pathMatch.IsMatch(pathStack.Path); while (i < length && IsWhiteSpace(json[i])) { i++; } if (i == length) { throw new JsonParseException("Invalid object; unexpected end of input"); } if (json[i++] != ':') { throw new JsonParseException("Invalid object; expected ':' field delimiter"); } if (i == length) { throw new JsonParseException("Invalid object; unexpected end of input"); } while (i < length && IsWhiteSpace(json[i])) { i++; } if (i == length) { throw new JsonParseException("Invalid object; unexpected end of input"); } i = ParseValue(json, i, parentPathMatched); var objectEndIndex = i; if (pathMatched) { EmitExtent(json, objectStartIndex, objectEndIndex); } else if (parentPathMatched && string.CompareOrdinal(name, extentId) == 0) { identityExtent = new JsonExtent(json, objectStartIndex, objectEndIndex - objectStartIndex); } pathStack.Pop(); fields++; } } if (i >= length) { throw new JsonParseException("Invalid object; unexpected end of input"); } return(i + 1); }