In 'angular2/di' the symbol: - Inject is a decorator - InjectAnnotation is an annotation Internally one an get a hold of annotations without *Annotations appened (to make ts2dart work without workarounds) by importing from 'angular2/src/di/annotations_impl' instead of 'angular2/di'. This is needed only for users that transpile through TS and through ts2dart.
31 lines
917 B
JavaScript
31 lines
917 B
JavaScript
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
|
import {isBlank, isPresent, BaseException, CONST} from 'angular2/src/facade/lang';
|
|
import {Pipe} from './pipe';
|
|
import {Injectable} from 'angular2/src/di/annotations_impl';
|
|
import {ChangeDetectorRef} from '../change_detector_ref';
|
|
|
|
@Injectable()
|
|
export class PipeRegistry {
|
|
config;
|
|
|
|
constructor(config){
|
|
this.config = config;
|
|
}
|
|
|
|
get(type:string, obj, cdRef:ChangeDetectorRef):Pipe {
|
|
var listOfConfigs = this.config[type];
|
|
if (isBlank(listOfConfigs)) {
|
|
throw new BaseException(`Cannot find '${type}' pipe supporting object '${obj}'`);
|
|
}
|
|
|
|
var matchingConfig = ListWrapper.find(listOfConfigs,
|
|
(pipeConfig) => pipeConfig.supports(obj));
|
|
|
|
if (isBlank(matchingConfig)) {
|
|
throw new BaseException(`Cannot find '${type}' pipe supporting object '${obj}'`);
|
|
}
|
|
|
|
return matchingConfig.create(cdRef);
|
|
}
|
|
}
|