Class TileProviderRegistry
- Namespace
- LansMap.Map.TilePipeline.Config
Where code-supplied tile providers are registered so scenes can select them by id. See TileProviderDefinition.
public static class TileProviderRegistry
- Inheritance
-
objectTileProviderRegistry
Remarks
Registrations do not survive a domain reload: recompiling or a
scripting-runtime restart empties this. Register from a
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
method so every id is present before any scene's maps start. Do not
register from Awake, Start or any other scene code: a map
in the same scene may build its pipeline first and find nothing.
That method runs again on every Play press, and with Project Settings > Editor > Enter Play Mode Options set to Reload Domain disabled the previous registrations are still here when it does. Re-registering the same definition is therefore allowed and does nothing, so the same initializer works either way. See Register(TileProviderDefinition) for what counts as the same definition.
Properties
RegisteredIds
Every registered id, in registration order. Empty before the first Register(TileProviderDefinition) call of the current domain.
public static IReadOnlyList<string> RegisteredIds { get; }
Property Value
Methods
ClearRegistrationsForTests()
Empties the registry. For tests that register their own definitions and must not leak them into the next test.
public static void ClearRegistrationsForTests()
Register(TileProviderDefinition)
Adds a provider definition under its own Id. Registering the same definition again under the same id does nothing; registering a different one under an id already taken is an error.
public static void Register(TileProviderDefinition definition)
Parameters
definitionTileProviderDefinitionThe definition. Its
Idmust be non-empty and itsCreateDependenciesmust be set.
Remarks
"The same definition" means the same object, or one whose
Id, DisplayName and Styles match string for
string, whose RequiresApiKey and SupportsRetina512
match, and whose CreateDependencies is the same method on
the same target. A static method, a method group, or a lambda that
captures nothing all satisfy the last part on a replayed
initializer; a lambda that captures fresh state each pass does not,
so register through one of the first three if your initializer can
run twice.
Exceptions
- ArgumentNullException
The definition is null.
- ArgumentException
The Id is empty or whitespace, or
CreateDependenciesis null.- InvalidOperationException
A different definition is already registered under that Id.
TryGet(string, out TileProviderDefinition)
Looks a definition up by the id a scene stored.
public static bool TryGet(string id, out TileProviderDefinition definition)
Parameters
idstringThe id; null or empty always misses.
definitionTileProviderDefinitionThe definition, or null on a miss.
Returns
- bool
True when the id resolves.