Skip to content

RemoteRepositoryCatalogProvider

ClassAssetInventoryAssetInventory.Editor
public abstract class RemoteRepositoryCatalogProvider : RemoteCatalogProviderBase, IRemoteCatalogProvider, IRemoteCatalogAccessProbe

Supports repository-backed catalog providers with validated revision snapshots, paged item filtering and pinned file downloads.

RemoteRepositoryCatalogProvider(HttpClient)

Section titled “RemoteRepositoryCatalogProvider(HttpClient)”
protected RemoteRepositoryCatalogProvider(HttpClient client = null)

Initializes repository access and shares immutable revision caches only when no custom HTTP client is supplied.

Parameters

Name Type
client System.Net.Http.HttpClient

LoadRepositoryAsync(string, CancellationToken, string)

Section titled “LoadRepositoryAsync(string, CancellationToken, string)”
protected Task<RemoteRepositoryCatalogProvider.RepositorySnapshot> LoadRepositoryAsync(string repository, CancellationToken cancellationToken, string expectedRevision = null)

Loads and caches a validated GitHub file tree at the requested immutable revision, resolving HEAD when no revision is supplied.

Parameters

Name Type
repository System.String
cancellationToken System.Threading.CancellationToken
expectedRevision System.String

Returns

System.Threading.Tasks.Task{AssetInventory.RemoteRepositoryCatalogProvider.RepositorySnapshot}

CatalogAsync(RepositorySnapshot, Func<RepositorySnapshot, CancellationToken, Task<List>>, CancellationToken)

Section titled “CatalogAsync(RepositorySnapshot, Func<RepositorySnapshot, CancellationToken, Task<List>>, CancellationToken)”
protected Task<List<RemoteCatalogItem>> CatalogAsync(RemoteRepositoryCatalogProvider.RepositorySnapshot snapshot, Func<RemoteRepositoryCatalogProvider.RepositorySnapshot, CancellationToken, Task<List<RemoteCatalogItem>>> build, CancellationToken cancellationToken)

Maps the items of an immutable revision once, so reading a catalog page by page does not map the whole repository for every page.

Parameters

Name Type
snapshot AssetInventory.RemoteRepositoryCatalogProvider.RepositorySnapshot
build System.Func{AssetInventory.RemoteRepositoryCatalogProvider.RepositorySnapshot,System.Threading.CancellationToken,System.Threading.Tasks.Task{System.Collections.Generic.List{AssetInventory.RemoteCatalogItem}}}
cancellationToken System.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{System.Collections.Generic.List{AssetInventory.RemoteCatalogItem}}

TryGetTextAsync(RepositorySnapshot, string, CancellationToken, long)

Section titled “TryGetTextAsync(RepositorySnapshot, string, CancellationToken, long)”
protected Task<string> TryGetTextAsync(RemoteRepositoryCatalogProvider.RepositorySnapshot snapshot, string path, CancellationToken cancellationToken, long maximumBytes = 1048576)

Reads an optional text file of the pinned revision for richer metadata. Returns null when the file is absent or unreachable, so the catalog never depends on it.

Parameters

Name Type
snapshot AssetInventory.RemoteRepositoryCatalogProvider.RepositorySnapshot
path System.String
cancellationToken System.Threading.CancellationToken
maximumBytes System.Int64

Returns

System.Threading.Tasks.Task{System.String}

Page(IEnumerable, RemoteCatalogRequest, string)

Section titled “Page(IEnumerable, RemoteCatalogRequest, string)”
protected static RemoteCatalogPage Page(IEnumerable<RemoteCatalogItem> items, RemoteCatalogRequest request, string revision)

Filters items by name or identifier and returns a bounded offset page with its revision, total match count and continuation cursor.

Parameters

Name Type
items System.Collections.Generic.IEnumerable{AssetInventory.RemoteCatalogItem}
request AssetInventory.RemoteCatalogRequest
revision System.String

Returns

AssetInventory.RemoteCatalogPage

protected static int ReadOffset(string cursor)

Parses a nonnegative continuation offset, using zero for an absent cursor and rejecting malformed values.

Parameters

Name Type
cursor System.String

Returns

System.Int32

protected static string Required(JToken token, string name)

Returns a named JSON value as nonblank text, failing when the value is missing or empty.

Parameters

Name Type
token Newtonsoft.Json.Linq.JToken
name System.String

Returns

System.String

protected static string EscapePath(string path)

Escapes each forward-slash-separated path segment for a URL while preserving directory separators.

Parameters

Name Type
path System.String

Returns

System.String

protected static string Extension(string path)

Returns a path's lowercase file extension without its leading period, or null for a null path.

Parameters

Name Type
path System.String

Returns

System.String

protected static string Humanize(string value)

Replaces underscores and hyphens with spaces and trims the resulting label.

Parameters

Name Type
value System.String

Returns

System.String

protected static string Title(string value)

Converts a repository label's separators to spaces and applies invariant-culture title casing.

Parameters

Name Type
value System.String

Returns

System.String

protected static string DirectoryPath(string path)

Returns the portion before the final forward slash, or an empty string when the path has no directory.

Parameters

Name Type
path System.String

Returns

System.String

protected static void ValidateRelativePath(string path)

Rejects blank paths, leading slashes, backslashes, dot segments and colon-bearing path segments.

Parameters

Name Type
path System.String

Download(RepositorySnapshot, RepositoryFile, string)

Section titled “Download(RepositorySnapshot, RepositoryFile, string)”
protected static RemoteDownloadFile Download(RemoteRepositoryCatalogProvider.RepositorySnapshot snapshot, RemoteRepositoryCatalogProvider.RepositoryFile file, string path = null)

Builds a revision-pinned download descriptor with an optional destination path and reported size; repository blob hashes are not used as payload checksums.

Parameters

Name Type
snapshot AssetInventory.RemoteRepositoryCatalogProvider.RepositorySnapshot
file AssetInventory.RemoteRepositoryCatalogProvider.RepositoryFile
path System.String

Returns

AssetInventory.RemoteDownloadFile