| 535 | } |
| 536 | |
| 537 | public replace(toReplace: InjectionToken, options: any) { |
| 538 | if (options.isProvider && this.hasProvider(toReplace)) { |
| 539 | const originalProvider = this._providers.get(toReplace); |
| 540 | |
| 541 | return originalProvider!.mergeWith({ provide: toReplace, ...options }); |
| 542 | } else if (!options.isProvider && this.hasInjectable(toReplace)) { |
| 543 | const originalInjectable = this._injectables.get(toReplace); |
| 544 | |
| 545 | return originalInjectable!.mergeWith({ |
| 546 | provide: toReplace, |
| 547 | ...options, |
| 548 | }); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | public hasProvider(token: InjectionToken): boolean { |
| 553 | return this._providers.has(token); |