in lib/object-context.ts [157:210]
public create(input: any): any {
if (Array.isArray(input)) {
if (input.length == 0) {
return input;
}
if (typeof input[0] == 'string') {
let uris: Uri[] = [];
let success = input.every((uri: string) => {
let ret = Uri.tryParse(uri);
if (ret.success) {
uris.push(ret.uri);
}
return ret.success;
});
if (!success) {
// If any of string is not URI, return itself.
return input;
}
let provider = this.selectProvider(uris[0], input);
return provider.provide(uris, this);
}
else if (typeof input[0] === 'object') {
if (input[0].hasOwnProperty('_type')) {
let typeName = input[0]['_type'];
let factory = this.selectFactory(typeName, input);
return factory.create(input, this);
}
}
return input;
}
else if (typeof input === 'string') {
let ret = Uri.tryParse(input);
if (ret.success) {
// Input is URI, select object provider from current scope to ancesters.
let uri = ret.uri;
let provider = this.selectProvider(uri, input);
return provider.provide(uri, this);
}
else {
// If a string is not URI, return itself.
return input;
}
}
else if (typeof input === 'object') {
// Object with type.
if (input.hasOwnProperty('_type')) {
let typeName = input['_type'];
let factory = this.selectFactory(typeName, input);
return factory.create(input, this);
}
}
return input;
}