##// END OF EJS Templates
fixed bug in applying a lifetime while processing the json configuration...
cin -
r152:8bee6a6d5f46 v1.4.0-rc10 default
parent child
Show More
@@ -66,7 +66,7 export class TemplateParser implements I
66 66 }
67 67
68 68 value() {
69 if (!this._value)
69 if (this._value === undefined)
70 70 throw new Error("The current token doesn't have a value");
71 71 return this._value;
72 72 }
@@ -38,10 +38,17 compile.load = (id: string, require: Req
38 38 trace.debug("{0}: compiled", url);
39 39 callback(cache[url] = tc);
40 40 }, (err: any) => {
41 callback.error({
42 inner: err,
43 src: "@implab/core/text/template-compile"
44 });
41 if (callback.error)
42 callback.error({
43 inner: err,
44 from: "@implab/core/text/template-compile"
45 });
46 else
47 trace.error({
48 message: `Failed to load: ${url}`,
49 error: err,
50 from: "@implab/core/text/template-compile"
51 });
45 52 });
46 53 }
47 54 };
@@ -1,12 +1,14
1 export class ConfigError extends Error {
1 export class ConfigError {
2 2 inner?: {};
3 3
4 message: string;
5
4 6 path?: string;
5 7
6 8 configName?: string;
7 9
8 10 constructor(message: string, inner?: {}) {
9 super(message);
11 this.message = message;
10 12 this.inner = inner;
11 13 }
12 14 }
@@ -6,7 +6,7 import {
6 6 ILifetime, ServiceContainer
7 7 } from "./interfaces";
8 8
9 import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get, primitive } from "../safe";
9 import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get, primitive, oid, mixin } from "../safe";
10 10 import { AggregateDescriptor } from "./AggregateDescriptor";
11 11 import { ValueDescriptor } from "./ValueDescriptor";
12 12 import { ReferenceDescriptor } from "./ReferenceDescriptor";
@@ -20,6 +20,7 import { ICancellation } from "../interf
20 20 import { isDescriptor } from "./traits";
21 21 import { LazyReferenceDescriptor } from "./LazyReferenceDescriptor";
22 22 import { LifetimeManager } from "./LifetimeManager";
23 import { ServiceDescriptorParams } from "./ServiceDescriptor";
23 24
24 25 export interface RegistrationScope<S extends object> {
25 26
@@ -339,8 +340,8 export class Configuration<S extends obj
339 340 }
340 341
341 342 _makeServiceParams(data: ServiceRegistration<any, S>) {
342 const opts: any = {
343 };
343 const opts: any = {};
344
344 345 if (data.services)
345 346 opts.services = this._visitRegistrations(data.services, "services");
346 347
@@ -361,7 +362,7 export class Configuration<S extends obj
361 362 this._visit(data.params, "params");
362 363
363 364 if (data.activation) {
364 opts.activation = this._getLifetimeManager(data.activation, data.typeId);
365 opts.lifetime = this._getLifetimeManager(data.activation, data.typeId);
365 366 }
366 367
367 368 if (data.cleanup)
@@ -395,7 +396,7 export class Configuration<S extends obj
395 396 argumentNotNull(data.$type, "data.$type");
396 397 this._enter(name);
397 398
398 const opts = this._makeServiceParams(data);
399 const opts = {} as any;
399 400 if (data.$type instanceof Function) {
400 401 opts.type = data.$type;
401 402 } else {
@@ -407,6 +408,11 export class Configuration<S extends obj
407 408 });
408 409 }
409 410
411 if (!data.typeId && data.activation === "singleton")
412 data.typeId = oid(opts.type);
413
414 mixin(opts, this._makeServiceParams(data));
415
410 416 const d = new TypeServiceDescriptor<S, any, any[]>(
411 417 await mapAll(opts)
412 418 );
@@ -420,6 +426,9 export class Configuration<S extends obj
420 426 argumentOfType(data.$factory, Function, "data.$factory");
421 427 this._enter(name);
422 428
429 if (!data.typeId && data.activation === "singleton")
430 data.typeId = oid(data.$factory);
431
423 432 const opts = this._makeServiceParams(data);
424 433 opts.factory = data.$factory;
425 434
@@ -149,7 +149,7 export function get(member: string, cont
149 149 * <c>this</c> в <c>cb</c>.
150 150 * @returns {void}
151 151 */
152 export function each<T>(obj: T, cb: <X extends keyof T>(v: NonNullable<T[X]>, k: X) => void): void;
152 export function each<T>(obj: T, cb: <X extends Extract<keyof T, string>>(v: NonNullable<T[X]>, k: X) => void): void;
153 153 export function each<T>(array: T[], cb: (v: T, i: number) => void): void;
154 154 export function each(obj: any, cb: any, thisArg?: any): any;
155 155 export function each(obj: any, cb: any, thisArg?: any) {
General Comments 0
You need to be logged in to leave comments. Login now