Table of Contents

Class PrefixAliasResolver

Namespace
TAssetBundle.Extensions
Assembly
TAssetBundle.Extensions.dll

Prefix-based alias resolver that maps user-facing path prefixes to one or more canonical folders, with an optional search-path fallback.

public sealed class PrefixAliasResolver : IAssetPathResolver
Inheritance
PrefixAliasResolver
Implements
Inherited Members

Remarks

Two operating modes per prefix:

  • Single folder: pure string substitution. Works without a catalog.
  • Multiple folders: search path. Uses AssetExists to find the first folder that contains the asset. Falls back to the first folder when no match is found or when AssetExists is not set.

Resolved results are cached. Call InvalidateCache() after a catalog change if the caller does not rely on automatic invalidation.

Longer prefixes match first, allowing nested namespaces to coexist.

Properties

AssetExists

Catalog existence predicate injected by the caller. Required only when any prefix has more than one folder. Typically wired to ExistAsset(AssetRef).

public Func<string, bool> AssetExists { get; set; }

Property Value

Func<string, bool>

Count

Number of registered prefixes.

public int Count { get; }

Property Value

int

Methods

Add(string, IEnumerable<string>)

Registers a prefix that maps to an ordered list of folders. The first folder that contains the asset wins. Re-adding an existing prefix overwrites the previous mapping.

public void Add(string prefix, IEnumerable<string> folders)

Parameters

prefix string
folders IEnumerable<string>

Add(string, string)

Registers a prefix that substitutes to a single folder.

public void Add(string prefix, string folder)

Parameters

prefix string
folder string

Clear()

Removes all registered prefixes.

public void Clear()

InvalidateCache()

Clears the resolution cache. Call this when the catalog changes (for example after UpdateCatalogAsync()).

public void InvalidateCache()

Remove(string)

Removes the given prefix if present. Returns true if removed.

public bool Remove(string prefix)

Parameters

prefix string

Returns

bool

Resolve(string)

Resolves the input path to a canonical full asset path.

public string Resolve(string inputPath)

Parameters

inputPath string

User-provided path, possibly containing an alias prefix.

Returns

string

Canonical full asset path. Returns the input unchanged if no alias matches.