AppLocator class¶
Defined in
Namespace: Splat
Assembly: Splat.Core.dll
Full name: Splat.AppLocator
Modifiers: public static
Summary¶
Provides a global access point for dependency resolution within the application, allowing services and types to be
registered and retrieved at runtime.
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Remarks¶
AppLocator exposes static members for resolving and registering dependencies using a default or custom dependency resolver. It is intended for use by both application code and libraries that require service location. In most scenarios, the default resolver is sufficient and should be used unless advanced customization or testing scenarios require replacing it. Thread safety and resolver change notifications are managed internally. For most applications, use the Current and CurrentMutable properties to access the dependency resolver.
Properties¶
| Name | Summary |
|---|---|
| static Current | Gets the read only dependency resolver. This class is used throughout libraries for many internal operations as well as for general use by applications. If this isn't... |
| static CurrentMutable | Gets the mutable dependency resolver. The default resolver is also a mutable resolver, so this will be non-null. Use this to register new types on startup if you are using... |
Methods¶
| Name | Summary |
|---|---|
| static RegisterResolverInitializer | Registers the action that initializes each resolver as it is set or reset for the application. |
| static SetLocator | Sets the dependency resolver to be used by the application. |
| static GetLocator | Gets the current dependency resolver instance used by the application. |
| static RegisterResolverCallbackChanged | This method allows libraries to register themselves to be set up whenever the dependency resolver changes. Applications should avoid this method, it is usually used for... |
| static SuppressResolverCallbackChangedNotifications | This method will prevent resolver changed notifications from happening until the returned IDisposable is disposed. |
| static AreResolverCallbackChangedNotificationsEnabled | Indicates if the we are notifying external classes of updates to the resolver being changed. |
| static GetService | Gets an instance of the given service type. Must return null if the service is not available (must not throw). |
| static GetServices | Gets all instances of the given service type. Must return an empty collection if the service is not available (must not return null or throw). |
| static HasRegistration | Check to see if a resolver has a registration for a type. |
| static Register | Register a function with the resolver which will generate an object for the specified service type. |
| static RegisterConstant | Registers a constant value which will always return the specified object instance. |
| static RegisterLazySingleton | Registers a lazy singleton value which will always return the specified object instance once created. The value is only generated once someone requests the service from the resolver. |
| static UnregisterCurrent | Unregisters the current the value for the specified type and the optional contract. |
| static UnregisterAll | Unregisters the all the values for the specified type and the optional contract. |