public virtual ODataPath Parse(Uri uri, Uri baseUri) { if (uri == null) { throw Error.ArgumentNull("uri"); } if (baseUri == null) { throw Error.ArgumentNull("baseUri"); } string uriPath = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped); string basePath = baseUri.GetComponents(UriComponents.Path, UriFormat.Unescaped); if (!uriPath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase)) { return(null); } string relativePath = uriPath.Substring(basePath.Length); ODataPath path = new ODataPath(); ODataPathSegment pathSegment = new ServiceBasePathSegment(baseUri); path.Segments.AddLast(pathSegment); foreach (string segment in ParseSegments(relativePath)) { pathSegment = ParseNextSegment(pathSegment, segment); // If the Uri stops matching the model at any point, return null if (pathSegment == null) { return(null); } path.Segments.AddLast(pathSegment); } return(path); }
public virtual ODataPath Parse(Uri uri, Uri baseUri) { if (uri == null) { throw Error.ArgumentNull("uri"); } if (baseUri == null) { throw Error.ArgumentNull("baseUri"); } string uriPath = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped); string basePath = baseUri.GetComponents(UriComponents.Path, UriFormat.Unescaped); if (!uriPath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase)) { return null; } string relativePath = uriPath.Substring(basePath.Length); ODataPath path = new ODataPath(); ODataPathSegment pathSegment = new ServiceBasePathSegment(baseUri); path.Segments.AddLast(pathSegment); foreach (string segment in ParseSegments(relativePath)) { pathSegment = ParseNextSegment(pathSegment, segment); // If the Uri stops matching the model at any point, return null if (pathSegment == null) { return null; } path.Segments.AddLast(pathSegment); } return path; }