All files / src/Config snconfigfieldmodelstore.js

0% Statements 0/20
0% Branches 0/10
0% Functions 0/4
0% Lines 0/20
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 36 37                                                                         
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const snconfigbehavior_1 = require("./snconfigbehavior");
class SnConfigFieldModelStore {
    static Add(newModel) {
        if (!newModel.StoreKey) {
            throw Error('No Store key defined');
        }
        if (this.Contains(newModel.StoreKey)) {
            throw new Error(`Field ${newModel.StoreKey} for configuration model already in the store!`);
        }
        this._store[newModel.StoreKey] = newModel;
    }
    static Get(storeKey) {
        const found = this._store[storeKey];
        if (!found) {
            throw new Error(`No entry found with the field name '${storeKey}'`);
        }
        return this._store[storeKey];
    }
    static Contains(fieldName) {
        const found = this._store[fieldName];
        return found !== undefined;
    }
    static GetCommandOptions() {
        const items = [];
        for (const field in this._store) {
            if (field && (this._store[field].Behavior & snconfigbehavior_1.SnConfigBehavior.AllowFromCommandLine) === snconfigbehavior_1.SnConfigBehavior.AllowFromCommandLine) {
                items.push(this._store[field]);
            }
        }
        return items;
    }
}
SnConfigFieldModelStore._store = [];
exports.SnConfigFieldModelStore = SnConfigFieldModelStore;
//# sourceMappingURL=snconfigfieldmodelstore.js.map