public static Path ParseWithContainer(string path) { if (_parsedLocationCache.ContainsKey(path)) { return(_parsedLocationCache[path]); } var endswithslash = path.LastIndexOfAny(Slashes) == path.Length; var pathToParse = (path ?? string.Empty).UrlDecode(); var match = UriRx.Match(pathToParse); if (match.Success) { pathToParse = match.Groups[3].Value; } var segments = pathToParse.Split(Slashes, StringSplitOptions.RemoveEmptyEntries); return(_parsedLocationCache.AddOrSet(path, new Path { HostAndPort = segments.Length > 0 ? segments[0] : string.Empty, Container = segments.Length > 1 ? segments[1] : string.Empty, Parts = segments.Length > 2 ? segments.Skip(2).ToArray() : new string[0], SubPath = segments.Length > 2 ? segments.Skip(2).Aggregate((current, each) => current + Slash + each) : string.Empty, ParentPath = segments.Length > 3 ? segments.Skip(2).Take(segments.Length - 3).Aggregate((current, each) => current + Slash + each) : string.Empty, Name = segments.Length > 2 ? segments.Last() : string.Empty, StartsWithSlash = pathToParse.IndexOfAny(Slashes) == 0, EndsWithSlash = endswithslash, // pathToParse.LastIndexOfAny(Slashes) == pathToParse.Length, Scheme = match.Success ? match.Groups[1].Value.ToLower() : string.Empty, OriginalPath = path, })); }
public static IDictionary<string, string> GetSubjectNameParts(this X509Certificate2 cert) { var result = new XDictionary<string, string>(); foreach (var bits in cert.SubjectName.Name.SplitToList(',').Select(each => each.Split('='))) { var newKey = bits[0].Trim(' '); result.Add(result.ContainsKey(newKey) ? newKey + result.Keys.Where(key => key.StartsWith(newKey)).Count() : newKey, bits[1]); } return result; }
public static IDictionary <string, string> GetSubjectNameParts(this X509Certificate2 cert) { var result = new XDictionary <string, string>(); foreach (var bits in cert.SubjectName.Name.SplitToList(',').Select(each => each.Split('='))) { var newKey = bits[0].Trim(' '); result.Add(result.ContainsKey(newKey) ? newKey + result.Keys.Where(key => key.StartsWith(newKey)).Count() : newKey, bits[1]); } return(result); }
public static void AddChildren(this XDictionary <string, string> propertyDictionary, IEnumerable <XElement> children) { foreach (var child in children) { var val = child.Value; var key = child.LocalName(); if (propertyDictionary.ContainsKey(key)) { var cur = propertyDictionary[key]; val = val.Replace("%({0})".format(key), cur); } val = Event <CustomReplacement> .Raise(val); propertyDictionary.Add(key, val); } }