CompositeFactory class Null safety
Aggregates multiple factories into a single factory component. When a new component is requested, it iterates through factories to locate the one able to create the requested component.
This component is used to conveniently keep all supported factories in a single place.
Example
var factory = new CompositeFactory();
factory.add(new DefaultLoggerFactory());
factory.add(new DefaultCountersFactory());
var loggerLocator = new Descriptor('*', 'logger', '*', '*', '1.0');
factory.canCreate(loggerLocator); // Result: Descriptor('pip-service', 'logger', 'null', 'default', '1.0')
factory.create(loggerLocator); // Result: created NullLogger
- Implemented types
Constructors
-
CompositeFactory(List<
IFactory> ? factories) - Creates a new instance of the factory. [...]
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
add(
IFactory? factory) → void - Adds a factory into the list of embedded factories. [...]
-
canCreate(
dynamic locator) → dynamic -
Checks if this factory is able to create component by given locator. [...]
override
-
create(
dynamic locator) → dynamic -
Creates a component identified by given locator. [...]
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
remove(
IFactory factory) → void - Removes a factory from the list of embedded factories. [...]
-
toString(
) → String -
A string representation of this object. [...]
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited