"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Value = void 0;
var CmUtils_1 = require("../utils/CmUtils");
var ConfigClient_1 = require("./ConfigClient");
var typescript_ioc_1 = require("typescript-ioc");
function Value(key) {
    return function (target, attr) {
        var client = typescript_ioc_1.Container.get(ConfigClient_1.ConfigClient);
        Reflect.defineProperty(target, attr, {
            configurable: true,
            enumerable: true,
            get: function () {
                if (CmUtils_1.CmUtils.isEmpty(key)) {
                    return undefined;
                }
                else {
                    var defaultValue = void 0;
                    var configKey = key;
                    if (key.indexOf(":") > -1) {
                        var arry = key.split(':');
                        configKey = arry[0];
                        defaultValue = arry[1];
                    }
                    var value = client.getConfig(configKey);
                    if (CmUtils_1.CmUtils.isNotEmpty(value)) {
                        return value;
                    }
                    else {
                        return defaultValue;
                    }
                }
            },
            set: function () { }
        });
    };
}
exports.Value = Value;
