MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / enableClassManagement

Function enableClassManagement

libs/echarts/echarts.simple.js:12323–12443  ·  view source on GitHub ↗

* @param {Object} entity * @param {Object} options * @param {boolean} [options.registerWhenExtend] * @public

(entity, options)

Source from the content-addressed store, hash-verified

12321 * @public
12322 */
12323function enableClassManagement(entity, options) {
12324 options = options || {};
12325
12326 /**
12327 * Component model classes
12328 * key: componentType,
12329 * value:
12330 * componentClass, when componentType is 'xxx'
12331 * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
12332 * @type {Object}
12333 */
12334 var storage = {};
12335
12336 entity.registerClass = function (Clazz, componentType) {
12337 if (componentType) {
12338 checkClassType(componentType);
12339 componentType = parseClassType$1(componentType);
12340
12341 if (!componentType.sub) {
12342 if (__DEV__) {
12343 if (storage[componentType.main]) {
12344 console.warn(componentType.main + ' exists.');
12345 }
12346 }
12347 storage[componentType.main] = Clazz;
12348 }
12349 else if (componentType.sub !== IS_CONTAINER) {
12350 var container = makeContainer(componentType);
12351 container[componentType.sub] = Clazz;
12352 }
12353 }
12354 return Clazz;
12355 };
12356
12357 entity.getClass = function (componentMainType, subType, throwWhenNotFound) {
12358 var Clazz = storage[componentMainType];
12359
12360 if (Clazz && Clazz[IS_CONTAINER]) {
12361 Clazz = subType ? Clazz[subType] : null;
12362 }
12363
12364 if (throwWhenNotFound && !Clazz) {
12365 throw new Error(
12366 !subType
12367 ? componentMainType + '.' + 'type should be specified.'
12368 : 'Component ' + componentMainType + '.' + (subType || '') + ' not exists. Load it first.'
12369 );
12370 }
12371
12372 return Clazz;
12373 };
12374
12375 entity.getClassesByMainType = function (componentType) {
12376 componentType = parseClassType$1(componentType);
12377
12378 var result = [];
12379 var obj = storage[componentType.main];
12380

Callers 1

echarts.simple.jsFile · 0.70

Calls 5

pushMethod · 0.80
checkClassTypeFunction · 0.70
parseClassType$1Function · 0.70
makeContainerFunction · 0.70
each$1Function · 0.70

Tested by

no test coverage detected