ManagedReferences

Managed references that in addition to keeping and locating references can also manage their lifecycle.

Inherits: ReferencesDecorator, IOpenable

Description

The ManagedReferences class allows you to create managed references that in additon to keeping and locating references can also manage their lifecycle, such as:

  • Auto-creation of missing components using available factories
  • Auto-linking newly added components
  • Auto-opening newly added components
  • Auto-closing removed components

Constructors

Creates a new instance of the decorator.

public ManagedReferences(object[] tuples = null)

  • tuples: object[] - tuples where odd values are component locators (descriptors) and even values are component references

Fields

_references

References

protected _references: References

_builder

Builder

protected _builder: BuildReferencesDecorator

_linker

Linker

protected _linker: LinkReferencesDecorator

_runner

Runner

protected _runner: RunReferencesDecorator

Instance methods

Close

Closes the component and frees used resources.

public Task CloseAsync(IContext context)

  • context: IContext - (optional) a context to trace execution through a call chain.

IsOpen

Checks if the component is open.

public bool IsOpen()

  • returns: bool - True if the component is open and False otherwise.

Open

Opens the component.

public Task OpenAsync(IContext context)

  • context: IContext - (optional) a context to trace execution through a call chain.

Static methods

FromTuples

Removes all component references that match the specified locator.

public static ManagedReferences FromTyples(params object[] tuples)

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

See also