/// <summary> /// Inspect a URI and determine the correct root and display URIs /// </summary> protected SleetUriPair GetUriPair(Uri path, bool caseSensitive) { if (path == null) { throw new ArgumentNullException(nameof(path)); } var isRoot = UriUtility.HasRoot(Root, path, caseSensitive); var isDisplay = UriUtility.HasRoot(BaseURI, path, caseSensitive); if (!isRoot && !isDisplay) { throw new InvalidOperationException($"URI does not match the feed root or baseURI: {path.AbsoluteUri}"); } var pair = new SleetUriPair() { BaseURI = path, Root = path }; if (!isRoot) { pair.Root = UriUtility.ChangeRoot(BaseURI, Root, path); } if (!isDisplay) { pair.BaseURI = UriUtility.ChangeRoot(Root, BaseURI, path); } return(pair); }
public ISleetFile Get(Uri path) { if (path == null) { Debug.Fail("bad path"); throw new ArgumentNullException(nameof(path)); } if (!path.AbsoluteUri.StartsWith(BaseURI.AbsoluteUri)) { throw new ArgumentException(string.Format("Base uri does not match the file system. Url: {0}, Expecting: {1}", path.AbsoluteUri, BaseURI.AbsoluteUri)); } var file = Files.GetOrAdd(path, (uri) => { var rootUri = uri; var displayUri = uri; if (!UriUtility.HasRoot(Root, rootUri)) { rootUri = UriUtility.ChangeRoot(BaseURI, Root, uri); } if (!UriUtility.HasRoot(BaseURI, displayUri)) { displayUri = UriUtility.ChangeRoot(Root, BaseURI, uri); } return(new PhysicalFile( this, rootUri, displayUri, LocalCache.GetNewTempPath(), new FileInfo(rootUri.LocalPath))); }); return(file); }