public void IsDecodable1() { string syntax = "a == \"b\""; FuzzyEqualEvaluator expect = new FuzzyEqualEvaluator(); var left = new LiteralValueEvaluator(); left.Value = "a"; expect.Left = left; var right = new LiteralValueEvaluator(); right.Value = "b"; expect.Right = right; IStringEvaluator actual = EvaluatorDecoder.decode(syntax); Assert.AreEqual(actual, expect); }
YamlPathInfo?findPath(RequestProxy requestProxy, HttpListenerContext httpContext) { var request = httpContext.Request; string path = request.Url.LocalPath; string method = request.HttpMethod.ToLower(); foreach (var p in settings.paths) { if (p.path != path) { continue; } if (!string.IsNullOrEmpty(p.methods) && !p.methods.ToLower().Split(',').Contains(method)) { continue; } if (!string.IsNullOrEmpty(p.filter)) { try { IStringEvaluator evoluator = EvaluatorDecoder.decode(p.filter); var context = new RequestMatchingContext(); context.PathInfo = p; context.Request = requestProxy; context.HttpContext = httpContext; if (evoluator.evoluate(context) != StringEvaluator.TRUE) { continue; } } catch (FormatException ex) { log.error("ERROR! filter syntax is broken. filter: " + p.filter + " reason:" + ex.ToString()); } } return(p); } return(null); }