ContainerConfigure class final
Service container configuration.
Provide a way to configure the service container, e.g. by rewriting the value of the service descriptor in order to replace the implementation of the service.
Usage:
By adding extension methods on ContainerConfigure, you can configure the overridable service descriptors in different packages uniformly,
then you can do this:
SingletonDescriptor<String> $String = SingletonDescriptor((p) => "Hello World");
extension MyContainerConfigureExtension on ContainerConfigure {
void configureMyService() {
$String = SingletonDescriptor((p) => "Hi, World");
}
}
void main() {
// Configure the service container before using it
containerConfigure.configureMyService();
final p = ServiceProvider();
final s = p.getService($String);
print(s);
}
In this way, you can configure the overridable service descriptors in different packages uniformly to replace different service implementations.
- Available extensions
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
-
enableDebugLogging(
) → void -
Available on ContainerConfigure, provided by the ServiceContainerLogging extension
Enable logging for debug mode. Logging only available in debug mode, so you have to make sure call this method inassert
orkDebugMode
block, call this method in non-debug mode will not have any effect. -
enableDebugLogPrinter(
IServiceProvider p) → void -
Available on ContainerConfigure, provided by the ServiceContainerLogging extension
Listen to onRecord and use $LogPrinter service to print logs. Call this method will enable debug logging. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- loggingEnabled → bool
-
Whether logs for service containers are enabled.
no setter
-
onRecord
→ Stream<
LogRecord> ? -
Get the logger stream for service container. if loggingEnabled is
false
, it will returnnull
.no setter