Interface that can be used to decorate the lookup result for a set of types.
Inheritance Hierarchy
ILookupDecorator
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.ILookupDecorator
See Also
ILookup,
IContextLookupChainLink,
Removing a Decoration,
The Lookup Chain,
Examples for Lookup Decoration
Methods
add
<TContext,TResult>(contextType: Class, resultType: Class, factory: function(TContext):TResult, nullIsFallback?: boolean) : IContextLookupChainLinkAdds a lookup implementation for a given type using a func.
Type Parameters
- TContext
- The type of the context subject.
- TResult
- The type of the query, which is a base type or the type of the result.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- contextType - Class
- resultType - Class
- factory - function(TContext):TResult
- The factory delegate that will be used to satisfy queries of type
TResult
.Signature Details
function(item: TContext) : TResult
A function which provides a custom into a custom implementation ofTInterface
for the givenitem
.Parameters
- item - TContext
- The item to return the implementation for.
Returns
- TResult
- The new implementation.
- nullIsFallback - boolean
- Whether to treat
null
-results of thefactory
as hints to use the remainder of the chain link or to actually yield the value as the final result.
Returns
- ↪IContextLookupChainLink
- The IContextLookupChainLink instance as returned by the addLookup call or
null
, if eitherdecorator
wasnull
, or it could not decorate theTContext
type.
add
<TContext,TResult>(contextType: Class, resultType: Class, wrapperFactory: function(TContext, TResult):TResult, decorateNull?: boolean) : IContextLookupChainLinkAdds a lookup implementation for a given type using a function of type function(TContext, TResult)
.
Remarks
This method is closely related to the add method, however it passes the result of the remaining chain to the delegate for convenient wrapping of the result. Note that if the implementation does not depend on the previous result in order to wrap it, it is better to use that variant, in order to avoid the possibly costly evaluation of the remainder of the lookup chain.
Type Parameters
- TContext
- The type of the context subject.
- TResult
- The type of the query, which is a base type or the type of the result.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- contextType - Class
- resultType - Class
- wrapperFactory - function(TContext, TResult):TResult
- The factory delegate that will be used to satisfy queries of type
TResult
Signature Details
function(item: TContext, originalImplementation: TResult) : TResult
A function which wraps theoriginalImplementation
ofTInterface
into a custom implementation for the givenitem
.Parameters
- item - TContext
- The item to return the wrapped implementation for.
- originalImplementation - TResult
- The original implementation to wrap.
Returns
- TResult
- The new implementation.
- decorateNull - boolean
- Whether to actually decorate
null
results of remainder of the chain. If this is set tofalse
, thewrapperFactory
will never be called withnull
as the second argument but the result of the query for this chain link will be thenull
value.
Returns
- ↪IContextLookupChainLink
- The IContextLookupChainLink instance as returned by the addLookup call or
null
, if eitherdecorator
wasnull
, or it could not decorate theTContext
type.
See Also
addConstant
<TContext,TResult>(contextType: Class, resultType: Class, result: TResult) : IContextLookupChainLinkAdd a lookup implementation for a given type that always yields a constant result.
Type Parameters
- TContext
- The type of the context subject.
- TResult
- The type of the query, which is a base type or the type of the result.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- contextType - Class
- resultType - Class
- result - TResult
- The constant value to yield if the chain is queried for an implementation of type
TResult
.
Returns
- ↪IContextLookupChainLink
- The IContextLookupChainLink instance as returned by the addLookup call or
null
, if eitherdecorator
wasnull
, or it could not decorate theTContext
type.
See Also
Adds a lookup chain element to the chain of lookups for a given type.
Remarks
The lookup chain is context specific. This method will not generally decorate the lookup of all instances of type
t
, but only those that stand in context of this instance. This method will only succeed if canDecorate yields true
for t
.Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- t - Class
- The type to decorate the lookup.
- lookup - IContextLookupChainLink
- The chain element to add to the lookup of the given type.
See Also
Removes a previously registered lookup chain element from the chain of lookups for a given type.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- t - Class
- The type to remove the decorator from.
- lookup - IContextLookupChainLink
- The chain element to remove from the lookup of the given type.