ServiceDescriptor class

Describes a service with its service type, implementation, and lifetime.

Adapted from ServiceDescriptor.cs

Constructors

ServiceDescriptor({required Type serviceType, ServiceLifetime lifetime = ServiceLifetime.singleton, Object? serviceKey, Object? implementationInstance, Object? implementationFactory})

Properties

hashCode int
The hash code for this object.
no setteroverride
implementationFactory ImplementationFactory?
Gets the factory used for creating service instances.
no setter
implementationInstance Object?
Gets the instance that implements the service.
no setter
isKeyedService bool
Indicates whether the service is a keyed service.
no setter
keyedImplementationFactory KeyedImplementationFactory?
Gets the factory used for creating service instances.
no setter
keyedImplementationInstance Object?
Gets the instance that implements the service.
no setter
lifetime ServiceLifetime
Gets the ServiceLifetime of the service.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceKey Object?
Get the key of the service, if applicable.
final
serviceType Type
Gets the Type of the service.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
throwKeyedDescriptor() → void
throwNonKeyedDescriptor() → void
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
Equality comparison based on service type, lifetime, implementation type/instance/factory, and service key.
override

Static Methods

keyedScoped<TService>(Object? serviceKey, ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, implementationFactory and the ServiceLifetime.scoped.
keyedSingleton<TService>(Object? serviceKey, ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, serviceKey, implementationFactory and the ServiceLifetime.singleton lifetime.
keyedSingletonInstance<TService>(Object? serviceKey, Object implementationInstance) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified serviceKey, implementationInstance, and the ServiceLifetime.singleton lifetime.
keyedTransient<TService>(Object? serviceKey, ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, and the ServiceLifetime.transient lifetime.
scoped<TService>(ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, implementationFactory and the ServiceLifetime.scoped.
singleton<TService>(ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, implementationFactory and the ServiceLifetime.singleton.
singletonInstance<TService>(Object implementationInstance) ServiceDescriptor
transient<TService>(ImplementationFactory implementationFactory) ServiceDescriptor
Creates an instance of ServiceDescriptor with the specified TService, implementationFactory and the ServiceLifetime.transient.