all files / grid/services/ service-locator.js

100% Statements 21/21
100% Branches 8/8
100% Functions 6/6
100% Lines 21/21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35   1195×   9641× 9640×     102244×   102243×   491× 39× 39×     452×            
define(["require", "exports", "@syncfusion/ej2-base", "../renderer/responsive-dialog-renderer"], function (require, exports, ej2_base_1, responsive_dialog_renderer_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ServiceLocator = (function () {
        function ServiceLocator() {
            this.services = {};
        }
        ServiceLocator.prototype.register = function (name, type) {
            if (ej2_base_1.isNullOrUndefined(this.services["" + name])) {
                this.services["" + name] = type;
            }
        };
        ServiceLocator.prototype.getService = function (name) {
            if (ej2_base_1.isNullOrUndefined(this.services["" + name])) {
                throw "The service " + name + " is not registered";
            }
            return this.services["" + name];
        };
        ServiceLocator.prototype.registerAdaptiveService = function (type, isAdaptiveUI, action) {
            if (isAdaptiveUI) {
                type.responsiveDialogRenderer = new responsive_dialog_renderer_1.ResponsiveDialogRenderer(type.parent, type.serviceLocator);
                type.responsiveDialogRenderer.action = action;
            }
            else {
                if (type.responsiveDialogRenderer) {
                    type.responsiveDialogRenderer.removeEventListener();
                    type.responsiveDialogRenderer = undefined;
                }
            }
        };
        return ServiceLocator;
    }());
    exports.ServiceLocator = ServiceLocator;
});