##// END OF EJS Templates
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version

File last commit:

r144:f97a113c3209 v1.4.0-rc4 default
r146:f3f5c56d3b3e v1.4.0-rc5 default
Show More
FluentConfiguration.ts
68 lines | 2.3 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / fluent / FluentConfiguration.ts
cin
Completely removed IoC annotations...
r135 import { argumentNotNull, each, isPrimitive, isPromise } from "../../safe";
import { DescriptorBuilder } from "./DescriptorBuilder";
cin
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
r142 import { RegistrationBuilder, FluentRegistrations, ContainerConfiguration } from "./interfaces";
cin
Completely removed IoC annotations...
r135 import { Cancellation } from "../../Cancellation";
cin
Fixed container interfaces, separated ServiceContainer
r144 import { ServiceContainer } from "../interfaces";
cin
Completely removed IoC annotations...
r135
export class FluentConfiguration<S extends object, Y extends keyof S = keyof S> {
_builders: { [k in keyof S]?: RegistrationBuilder<S, S[k]> } = {};
cin
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
r142 provided<K extends Y>(): FluentConfiguration<S, Exclude<Y, K>> {
return this;
}
cin
Completely removed IoC annotations...
r135 register<K extends Y>(name: K, builder: RegistrationBuilder<S, S[K]>): FluentConfiguration<S, Exclude<Y, K>>;
register<K extends Y>(config: FluentRegistrations<K, S>): FluentConfiguration<S, Exclude<Y, K>>;
register<K extends Y>(nameOrConfig: K | FluentRegistrations<K, S>, builder?: RegistrationBuilder<S, S[K]>): FluentConfiguration<S, Exclude<Y, K>> {
if (isPrimitive(nameOrConfig)) {
argumentNotNull(builder, "builder");
this._builders[nameOrConfig] = builder;
} else {
each(nameOrConfig, (v, k) => this.register(k, v));
}
return this;
}
cin
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
r142 configure(config: FluentRegistrations<Y, S>): ContainerConfiguration<S> {
return this.register(config);
}
cin
Fixed container interfaces, separated ServiceContainer
r144 apply<S2 extends object>(target: ServiceContainer<S2>, ct = Cancellation.none) {
cin
Completely removed IoC annotations...
r135
let pending = 1;
cin
Fixed container interfaces, separated ServiceContainer
r144 const _t2 = target as unknown as ServiceContainer<S2 & S>;
cin
tests
r136
cin
Fixed container interfaces, separated ServiceContainer
r144 return new Promise<ServiceContainer<S2 & S>>((resolve, reject) => {
cin
Completely removed IoC annotations...
r135 function guard(v: void | Promise<void>) {
if (isPromise(v))
v.catch(reject);
}
function complete() {
if (!--pending)
cin
tests
r136 resolve(_t2);
cin
Completely removed IoC annotations...
r135 }
each(this._builders, (v, k) => {
pending++;
cin
Fixed container interfaces, separated ServiceContainer
r144 const d = new DescriptorBuilder<S2 & S, any>(_t2,
cin
Completely removed IoC annotations...
r135 result => {
cin
tests
r136 _t2.register(k, result);
cin
Completely removed IoC annotations...
r135 complete();
},
reject
);
try {
guard(v(d, ct));
} catch (e) {
reject(e);
}
});
complete();
});
}
}