Class BundleProvider
- Namespace
- BlazOrbit.Localization.Providers
- Assembly
- BlazOrbit.Core.dll
Built-in provider that resolves a hash against the per-culture translation tables baked into the calling BobLocalizationBundleSpec by the source generator. Stateless, thread-safe, singleton.
public sealed class BundleProvider : IBobLocalizationProvider
- Inheritance
-
objectBundleProvider
- Implements
Remarks
Lookup strategy per call: test the requested culture against the calling bundle's
translation table, then its parent chain, then the bundle's DefaultCulture. The
first matching entry wins. The lookup is strictly scoped to the calling bundle - other
registered bundles are never consulted, even when they happen to share the same source
literal (and therefore the same hash).
In the fast path (call sites the source generator can resolve at build time) the accessor method skips this provider entirely - the generator emits a per-bundle static class with a direct System.Collections.Frozen.FrozenDictionary<TKey, TValue> lookup. This runtime provider serves the dynamic-key slow path.
Constructors
BundleProvider()
public BundleProvider()
Methods
TryGet(BobLocalizationBundleSpec, ulong, CultureInfo, out string?)
Attempts to resolve a translation for the given hash in the
requested culture, scoped to spec's bundle.
public bool TryGet(BobLocalizationBundleSpec spec, ulong hash, CultureInfo culture, out string? value)
Parameters
specBobLocalizationBundleSpecCalling bundle's spec. Providers MUST scope their lookup to this bundle - querying a global registry would allow another bundle that happens to share the same source literal (and therefore the same hash) to leak its translation back to the caller.
hashulongFNV-1a 64-bit hash of the source literal, precomputed at build time.
cultureCultureInfoCulture to resolve against; provider applies its own fallback rules within.
valuestringReceives the translation when this provider has a hit; null otherwise.