/// <summary> /// /// </summary> /// <param name="urlNodes"></param> /// <param name="urlParts"></param> /// <param name="methodInfo"></param> /// <param name="needsExplicitAuthentication"></param> private static void AddNode(IDictionary <string, UrlNode> urlNodes, IEnumerable <String> urlParts, MethodInfo methodInfo, Boolean needsExplicitAuthentication) { var val = urlParts.FirstOrDefault(); if (val == null) { throw new ArgumentException("The enumerable does not contain a value.", "urlParts"); } #region SpeedUp by removing all between {...} if (val.StartsWith("{") && val.EndsWith("}")) // something like /{....} or .{....} or ?{.....} will be changed to /{} .{} ?{} { val = "{}"; } #endregion UrlNode curUrlNode; #region Use an existing node or add a new one if (urlNodes.ContainsKey(val)) { curUrlNode = urlNodes[val]; } else { curUrlNode = new UrlNode { NeedsExplicitAuthentication = needsExplicitAuthentication }; urlNodes.Add(val, curUrlNode); } #endregion #region If there are some more parts proceed or set the methodInfo for the last part if (urlParts.Count() > 1) { // there are still some more parts of the URL AddNode(curUrlNode.ChildNodes, urlParts.Skip(1), methodInfo, needsExplicitAuthentication); } else { // this was the last one - take the methodInfo curUrlNode.Callback = methodInfo; } #endregion }
/// <summary> /// /// </summary> /// <param name="urlNodes"></param> /// <param name="urlParts"></param> /// <param name="methodInfo"></param> /// <param name="needsExplicitAuthentication"></param> private static void AddNode(IDictionary<string, UrlNode> urlNodes, IEnumerable<String> urlParts, MethodInfo methodInfo, Boolean needsExplicitAuthentication) { var val = urlParts.FirstOrDefault(); if (val == null) { throw new ArgumentException("The enumerable does not contain a value.", "urlParts"); } #region SpeedUp by removing all between {...} if (val.StartsWith("{") && val.EndsWith("}")) // something like /{....} or .{....} or ?{.....} will be changed to /{} .{} ?{} { val = "{}"; } #endregion UrlNode curUrlNode; #region Use an existing node or add a new one if (urlNodes.ContainsKey(val)) { curUrlNode = urlNodes[val]; } else { curUrlNode = new UrlNode { NeedsExplicitAuthentication = needsExplicitAuthentication }; urlNodes.Add(val, curUrlNode); } #endregion #region If there are some more parts proceed or set the methodInfo for the last part if (urlParts.Count() > 1) { // there are still some more parts of the URL AddNode(curUrlNode.ChildNodes, urlParts.Skip(1), methodInfo, needsExplicitAuthentication); } else { // this was the last one - take the methodInfo curUrlNode.Callback = methodInfo; } #endregion }