Mercurial > pub > ImplabJs
comparison src/implab/di/Container.js @ 1:93fb6c09f2e1
minor fixes
author | cin |
---|---|
date | Fri, 02 Jun 2017 18:15:22 +0300 |
parents | fc2517695ee1 |
children | 00779cb63b12 |
comparison
equal
deleted
inserted
replaced
0:fc2517695ee1 | 1:93fb6c09f2e1 |
---|---|
1 define([ | 1 define([ |
2 "../declare", | 2 "../declare", |
3 "../safe", | 3 "../safe", |
4 "../UUID", | 4 "../Uuid", |
5 "dojo/Deferred", | 5 "../Deferred", |
6 "./ActivationContext", | 6 "./ActivationContext", |
7 "./Descriptor", | 7 "./Descriptor", |
8 "./ValueDescriptor", | 8 "./ValueDescriptor", |
9 "./ReferenceDescriptor", | 9 "./ReferenceDescriptor", |
10 "./ServiceDescriptor", | 10 "./ServiceDescriptor", |
11 "./ActivationError" | 11 "./ActivationError" |
12 ], function ( | 12 ], function ( |
13 declare, | 13 declare, |
14 array, | |
15 safe, | 14 safe, |
16 UUID, | 15 Uuid, |
17 Deferred, | 16 Deferred, |
18 ActivationContext, | 17 ActivationContext, |
19 Descriptor, | 18 Descriptor, |
20 Value, | 19 Value, |
21 Reference, | 20 Reference, |
43 | 42 |
44 getParent: function () { | 43 getParent: function () { |
45 return this._parent; | 44 return this._parent; |
46 }, | 45 }, |
47 | 46 |
47 /** | |
48 * | |
49 */ | |
48 getService: function (name, def) { | 50 getService: function (name, def) { |
49 var d = this._services[name]; | 51 var d = this._services[name]; |
50 if (!d) | 52 if (!d) |
51 if (arguments.length > 1) | 53 if (arguments.length > 1) |
52 return def; | 54 return def; |
106 contextRequire = (opts && opts.contextRequire); | 108 contextRequire = (opts && opts.contextRequire); |
107 | 109 |
108 if (typeof (config) === "string") { | 110 if (typeof (config) === "string") { |
109 p = new Deferred(); | 111 p = new Deferred(); |
110 if (!contextRequire) { | 112 if (!contextRequire) { |
111 var shim = config + "-" + UUID(); | 113 var shim = config + "-" + Uuid(); |
112 define(shim, ["require", config], function (ctx, data) { | 114 define(shim, ["require", config], function (ctx, data) { |
113 p.resolve([data, { | 115 p.resolve([data, { |
114 contextRequire: ctx | 116 contextRequire: ctx |
115 }]); | 117 }]); |
116 }); | 118 }); |
226 opts.factory = data.$factory; | 228 opts.factory = data.$factory; |
227 | 229 |
228 if (data.services) | 230 if (data.services) |
229 opts.services = me._parseObject(data.services, typemap); | 231 opts.services = me._parseObject(data.services, typemap); |
230 if (data.inject) | 232 if (data.inject) |
231 opts.inject = data.inject instanceof Array ? array.map( | 233 opts.inject = data.inject instanceof Array ? data.inject.map(function (x) { |
232 data.inject, | 234 return me._parseObject(x, typemap); |
233 function (x) { | 235 }) : me._parseObject(data.inject, typemap); |
234 return me._parseObject(x, typemap); | |
235 }) : me._parseObject(data.inject, typemap); | |
236 if (data.params) | 236 if (data.params) |
237 opts.params = me._parse(data.params, typemap); | 237 opts.params = me._parse(data.params, typemap); |
238 | 238 |
239 if (data.activation) { | 239 if (data.activation) { |
240 if (typeof (data.activation) === "string") { | 240 if (typeof (data.activation) === "string") { |
286 if (data.constructor && | 286 if (data.constructor && |
287 data.constructor.prototype !== Array.prototype) | 287 data.constructor.prototype !== Array.prototype) |
288 return new Value(data, true); | 288 return new Value(data, true); |
289 | 289 |
290 var me = this; | 290 var me = this; |
291 return array.map(data, function (x) { | 291 return data.map(function (x) { |
292 return me._parse(x, typemap); | 292 return me._parse(x, typemap); |
293 }); | 293 }); |
294 } | 294 } |
295 | 295 |
296 }); | 296 }); |