References class
The most basic implementation of IReferences to store and locate component references.
See IReferences
Example
class MyController implements IReferenceable {
IMyPersistence persistence;
...
void setReferences(IReferences references) {
this.persistence = references.getOneRequired<IMyPersistence>(
new Descriptor("mygroup", "persistence", "*", "*", "1.0")
);
}
...
}
var persistence = new MyMongoDbPersistence();
var controller = new MyController();
var references = References.fromTuples([
new Descriptor("mygroup", "persistence", "mongodb", "default", "1.0"), persistence,
new Descriptor("mygroup", "controller", "default", "default", "1.0"), controller
]);
controller.setReferences(references);
- Implemented types
Constructors
- References([List tuples = null ])
- Creates a new instance of references and initializes it with references. [...]
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
-
find<
T> (dynamic locator, bool required) → List< T> -
- Gets all component references that match specified locator.
-
locator
the locator to find a reference by.
-
required
forces to raise an exception if no reference is found.
- Returns a list with matching component references.
- Throws a ReferenceException when required is set to true but no references found.
override - Gets all component references that match specified locator.
-
getAll(
) → List -
- Gets all component references registered in this reference map.
- Returns a list with component references.
override - Gets all component references registered in this reference map.
-
getAllLocators(
) → List -
- Gets locators for all registered component references in this reference map.
- Returns a list with component locators.
override - Gets locators for all registered component references in this reference map.
-
getOneOptional<
T> (dynamic locator) → T -
- Gets an optional component reference that matches specified locator.
-
locator
the locator to find references by.
- Returns a matching component reference or null if nothing was found.
override - Gets an optional component reference that matches specified locator.
-
getOneRequired<
T> (dynamic locator) → T -
- Gets a required component reference that matches specified locator.
-
locator
the locator to find a reference by.
- Returns a matching component reference.
- Throws a ReferenceException when no references found.
override - Gets a required component reference that matches specified locator.
-
getOptional<
T> (dynamic locator) → List< T> -
- Gets all component references that match specified locator.
-
locator
the locator to find references by.
- Returns a list with matching component references or empty list if nothing was found.
override - Gets all component references that match specified locator.
-
getRequired<
T> (dynamic locator) → List< T> -
- Gets all component references that match specified locator.
- At least one component reference must be present.
- If it doesn't the method throws an error.
-
locator
the locator to find references by.
- Returns a list with matching component references.
- Throws a ReferenceException when no references found.
override - Gets all component references that match specified locator.
-
put(
dynamic locator dynamic component) → void -
- Puts a new reference into this reference map.
-
locator
a locator to find the reference by.
-
component
a component reference to be added.
override - Puts a new reference into this reference map.
-
remove(
dynamic locator) → dynamic -
- Removes a previously added reference that matches specified locator.
override -
removeAll(
dynamic locator) → List -
- Removes all component references that match the specified locator.
-
locator
the locator to remove references by.
- Returns a list, containing all removed references.
override - Removes all component references that match the specified locator.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
fromTuples(
List tuples) → References - Creates a new References from a list of key-value pairs called tuples. [...]