private Dictionary <string, string> GetPathVariables(PatchObject patch, PatchListener listener) { var result = new Dictionary <string, string> (); // skip if rules count differ from patch if (patch.path.Length != listener.rules.Length) { return(null); } for (var i = 0; i < listener.rules.Length; i++) { var matches = listener.rules[i].Matches(patch.path[i]); if (matches.Count == 0 || matches.Count > 2) { return(null); } else if (listener.rawRules[i][0] == ':') { result.Add(listener.rawRules[i].Substring(1), matches[0].ToString()); } } return(result); }
private string[] CheckPatch(PatchObject patch, PatchListener listener) { // skip if rules count differ from patch if (patch.path.Length != listener.rules.Length) { return(new string[] { }); } List <string> pathVars = new List <string>(); for (var i = 0; i < listener.rules.Length; i++) { var matches = listener.rules[i].Matches(patch.path[i]); if (matches.Count == 0 || matches.Count > 2) { return(new string[] { }); } else if (matches[0].Groups.Count > 1) { pathVars.Add(matches[0].ToString()); // pathVars = pathVars.concat(matches.slice(1)); } } return(pathVars.ToArray()); }