internal static List <string> LookupFolder(Uri uri) { // The input URI may specify a folder which is invalid for pack URIs. If so, // create a valid pack URI by adding a fake filename. bool isFolder = IsFolderUri(uri); if (isFolder) { uri = new Uri(uri, FakeFileName); } // The input Uri should now be a valid absolute pack application Uri. // The caller (FontSourceCollection) guarantees that. // Perform a sanity check to make sure the assumption stays the same. Debug.Assert(uri.IsAbsoluteUri && uri.Scheme == PackUriHelper.UriSchemePack && BaseUriHelper.IsPackApplicationUri(uri)); Assembly uriAssembly; string escapedPath; BaseUriHelper.GetAssemblyAndPartNameFromPackAppUri(uri, out uriAssembly, out escapedPath); if (uriAssembly == null) { return(null); } // If we added a fake filename to the uri, remove it from the escaped path. if (isFolder) { Debug.Assert(escapedPath.EndsWith(FakeFileName, StringComparison.OrdinalIgnoreCase)); escapedPath = escapedPath.Substring(0, escapedPath.Length - FakeFileName.Length); } Dictionary <string, List <string> > folderResourceMap; lock (_assemblyCaches) { if (!_assemblyCaches.TryGetValue(uriAssembly, out folderResourceMap)) { folderResourceMap = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); ConstructFontResourceCache(uriAssembly, folderResourceMap); _assemblyCaches.Add(uriAssembly, folderResourceMap); } } List <string> ret; folderResourceMap.TryGetValue(escapedPath, out ret); return(ret); }