Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BuildReferencesDecorator

References decorator that automatically creates missing components using available component factories upon component retrival.

Hierarchy

Implements

  • any

Index

Constructors

constructor

  • Creates a new instance of the decorator.

    Parameters

    • nextReferences: IReferences

      the next references or decorator in the chain.

    • topReferences: IReferences

      the decorator at the top of the chain.

    Returns BuildReferencesDecorator

Properties

nextReferences

nextReferences: IReferences

The next references or decorator in the chain.

topReferences

topReferences: IReferences

The decorator at the top of the chain.

Methods

clarifyLocator

  • clarifyLocator(locator: any, factory: IFactory): any
  • Clarifies a component locator by merging two descriptors into one to replace missing fields. That allows to get a more complete descriptor that includes all possible fields.

    Parameters

    • locator: any

      a component locator to clarify.

    • factory: IFactory

      a factory that shall create the component.

    Returns any

    clarified component descriptor (locator)

create

  • create(locator: any, factory: IFactory): any
  • Creates a component identified by given locator.

    throws

    a CreateException if the factory is not able to create the component.

    see

    findFactory

    Parameters

    • locator: any

      a locator to identify component to be created.

    • factory: IFactory

      a factory that shall create the component.

    Returns any

    the created component.

find

  • find<T>(locator: any, required: boolean): T[]
  • Gets all component references that match specified locator.

    throws

    a [[ReferenceException]] when required is set to true but no references found.

    Type parameters

    • T

    Parameters

    • locator: any

      the locator to find a reference by.

    • required: boolean

      forces to raise an exception if no reference is found.

    Returns T[]

    a list with matching component references.

findFactory

  • findFactory(locator: any): IFactory
  • Finds a factory capable creating component by given descriptor from the components registered in the references.

    Parameters

    • locator: any

      a locator of component to be created.

    Returns IFactory

    found factory or null if factory was not found.

getAll

  • getAll(): any[]
  • Gets all component references registered in this reference map.

    Returns any[]

    a list with component references.

getAllLocators

  • getAllLocators(): any[]
  • Gets locators for all registered component references in this reference map.

    Returns any[]

    a list with component locators.

getOneOptional

  • getOneOptional<T>(locator: any): T
  • Gets an optional component reference that matches specified locator.

    Type parameters

    • T

    Parameters

    • locator: any

      the locator to find references by.

    Returns T

    a matching component reference or null if nothing was found.

getOneRequired

  • getOneRequired<T>(locator: any): T
  • Gets a required component reference that matches specified locator.

    throws

    a [[ReferenceException]] when no references found.

    Type parameters

    • T

    Parameters

    • locator: any

      the locator to find a reference by.

    Returns T

    a matching component reference.

getOptional

  • getOptional<T>(locator: any): T[]
  • Gets all component references that match specified locator.

    Type parameters

    • T

    Parameters

    • locator: any

      the locator to find references by.

    Returns T[]

    a list with matching component references or empty list if nothing was found.

getRequired

  • getRequired<T>(locator: any): 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.

    throws

    a [[ReferenceException]] when no references found.

    Type parameters

    • T

    Parameters

    • locator: any

      the locator to find references by.

    Returns T[]

    a list with matching component references.

put

  • put(locator: any, component: any): any
  • Puts a new reference into this reference map.

    Parameters

    • locator: any

      a locator to find the reference by.

    • component: any

      a component reference to be added.

    Returns any

remove

  • remove(locator: any): any
  • Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead.

    see

    removeAll

    Parameters

    • locator: any

      a locator to remove reference

    Returns any

    the removed component reference.

removeAll

  • removeAll(locator: any): any[]
  • Removes all component references that match the specified locator.

    Parameters

    • locator: any

      the locator to remove references by.

    Returns any[]

    a list, containing all removed references.

Generated using TypeDoc