@@ -39,18 +39,27 @@ import {
3939 SkipSelfMetadata
4040} from 'angular2/src/core/di/metadata' ;
4141import { AttributeMetadata } from 'angular2/src/core/metadata/di' ;
42+ import { ReflectorReader } from 'angular2/src/core/reflection/reflector_reader' ;
4243
4344@Injectable ( )
4445export class RuntimeMetadataResolver {
4546 private _directiveCache = new Map < Type , cpl . CompileDirectiveMetadata > ( ) ;
4647 private _pipeCache = new Map < Type , cpl . CompilePipeMetadata > ( ) ;
4748 private _anonymousTypes = new Map < Object , number > ( ) ;
4849 private _anonymousTypeIndex = 0 ;
50+ private _reflector : ReflectorReader ;
4951
5052 constructor ( private _directiveResolver : DirectiveResolver , private _pipeResolver : PipeResolver ,
5153 private _viewResolver : ViewResolver ,
5254 @Optional ( ) @Inject ( PLATFORM_DIRECTIVES ) private _platformDirectives : Type [ ] ,
53- @Optional ( ) @Inject ( PLATFORM_PIPES ) private _platformPipes : Type [ ] ) { }
55+ @Optional ( ) @Inject ( PLATFORM_PIPES ) private _platformPipes : Type [ ] ,
56+ _reflector ?: ReflectorReader ) {
57+ if ( isPresent ( _reflector ) ) {
58+ this . _reflector = _reflector ;
59+ } else {
60+ this . _reflector = reflector ;
61+ }
62+ }
5463
5564 private sanitizeTokenName ( token : any ) : string {
5665 let identifier = stringify ( token ) ;
@@ -78,7 +87,7 @@ export class RuntimeMetadataResolver {
7887 if ( dirMeta instanceof md . ComponentMetadata ) {
7988 assertArrayOfStrings ( 'styles' , dirMeta . styles ) ;
8089 var cmpMeta = < md . ComponentMetadata > dirMeta ;
81- moduleUrl = calcModuleUrl ( directiveType , cmpMeta ) ;
90+ moduleUrl = calcModuleUrl ( this . _reflector , directiveType , cmpMeta ) ;
8291 var viewMeta = this . _viewResolver . resolve ( directiveType ) ;
8392 assertArrayOfStrings ( 'styles' , viewMeta . styles ) ;
8493 templateMeta = new cpl . CompileTemplateMetadata ( {
@@ -148,7 +157,7 @@ export class RuntimeMetadataResolver {
148157 var meta = this . _pipeCache . get ( pipeType ) ;
149158 if ( isBlank ( meta ) ) {
150159 var pipeMeta = this . _pipeResolver . resolve ( pipeType ) ;
151- var moduleUrl = reflector . importUri ( pipeType ) ;
160+ var moduleUrl = this . _reflector . importUri ( pipeType ) ;
152161 meta = new cpl . CompilePipeMetadata ( {
153162 type : this . getTypeMetadata ( pipeType , moduleUrl ) ,
154163 name : pipeMeta . name ,
@@ -341,7 +350,8 @@ function isValidType(value: Type): boolean {
341350 return isPresent ( value ) && ( value instanceof Type ) ;
342351}
343352
344- function calcModuleUrl ( type : Type , cmpMetadata : md . ComponentMetadata ) : string {
353+ function calcModuleUrl ( reflector : ReflectorReader , type : Type ,
354+ cmpMetadata : md . ComponentMetadata ) : string {
345355 var moduleId = cmpMetadata . moduleId ;
346356 if ( isPresent ( moduleId ) ) {
347357 var scheme = getUrlScheme ( moduleId ) ;
0 commit comments