RunReferencesDecorator

References decorator that automatically opens to newly added components that implement the IOpenable interface and closes removed components that implement the IClosable interface.

Implements: ReferencesDecorator, IOpenable

Description

The RunReferencesDecorator class allows you to create a references decorator that automatically opens to newly added components that implement the IOpenable interface and closes removed components that implement the IClosable interface.

Constructors

Creates a new instance of the decorator.

RunReferencesDecorator(next_references: Optional[IReferences], top_references: Optional[IReferences])

  • next_references: Optional[IReferences] - next references or decorator in the chain.
  • top_references: Optional[IReferences] - decorator at the top of the chain.

Fields

_opened

Flag of the component state

_opened: boolean = false

Instance methods

put

Puts a new reference into the reference map.

put(locator: Any = None, reference: Any = None)

  • locator: Any - locator to find the reference by.
  • reference: Any - component reference to be added.

remove

Removes a previously added component that matches the specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use the remove_all method instead.

remove(locator: Any): Any

  • locator: Any - locator to remove component
  • returns: Any - removed component.

remove_all

Removes all component references that match the specified locator.

remove_all(locator: Any): List[Any]

  • locator: Any - locator to remove references by.
  • returns: List[Any] - list containing all removed references.

See also