ServiceLocator class
Service locator for dependency injection according to MCP UI DSL v1.0 specification
Constructors
- ServiceLocator.new()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Clear all services
-
createScope(
) → ServiceLocator - Create a scoped service locator
-
get<
T> ({bool optional = false}) → T - Get a service instance
-
getDependencies<
T> () → List< Type> ? - Get dependencies for a service
-
isRegistered<
T> () → bool - Check if a service is registered
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register<
T> (T service, {List< Type> ? dependencies}) → void - Register a singleton service
-
registerFactory<
T> (T factory(), {List< Type> ? dependencies}) → void - Register a factory (creates new instance each time)
-
registerLazy<
T> (T factory(), {List< Type> ? dependencies}) → void - Register a lazy singleton service
-
toString(
) → String -
A string representation of this object.
inherited
-
unregister<
T> () → void - Unregister a service
-
validateDependencies(
) → void - Validate dependencies (check for circular dependencies)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → ServiceLocator
-
no setter